if (settings->AsyncInput)
{
if (!(inputThread = CreateThread(NULL, 0,
- (LPTHREAD_START_ROUTINE) mac_client_input_thread, context, 0, NULL)))
+ (LPTHREAD_START_ROUTINE) mac_client_input_thread, context, 0, NULL)))
{
WLog_ERR(TAG, "failed to create async input thread");
goto disconnect;
else
{
if (!(inputEvent = freerdp_get_message_queue_event_handle(instance,
- FREERDP_INPUT_MESSAGE_QUEUE)))
+ FREERDP_INPUT_MESSAGE_QUEUE)))
{
WLog_ERR(TAG, "failed to get input event handle");
goto disconnect;
if (!settings->AsyncTransport)
{
if (!(nCountTmp = freerdp_get_event_handles(context, &events[nCount],
- 16 - nCount)))
+ 16 - nCount)))
{
WLog_ERR(TAG, "freerdp_get_event_handles failed");
break;
{
mfContext* mfc = (mfContext*) instance->context;
MRDPView* view = (MRDPView*) mfc->view;
-
PasswordDialog* dialog = [PasswordDialog new];
dialog.serverHostname = [NSString stringWithFormat:@"%@:%u",
- [NSString stringWithCString:instance->settings->ServerHostname encoding:NSUTF8StringEncoding],
- instance->settings->ServerPort];
+ [NSString stringWithCString:instance->settings->ServerHostname encoding:
+ NSUTF8StringEncoding],
+ instance->settings->ServerPort];
if (*username)
dialog.username = [NSString stringWithCString:*username encoding:
if (*domain)
dialog.domain = [NSString stringWithCString:*domain encoding:
- NSUTF8StringEncoding];
-
- [dialog performSelectorOnMainThread:@selector(runModal:) withObject:[view window] waitUntilDone:TRUE];
+ NSUTF8StringEncoding];
+ [dialog performSelectorOnMainThread:@selector(runModal:) withObject:[view
+ window] waitUntilDone:TRUE];
BOOL ok = dialog.modalCode;
- if (ok)
+ if (ok)
{
const char* submittedUsername = [dialog.username cStringUsingEncoding:
NSUTF8StringEncoding];
*username = malloc((strlen(submittedUsername) + 1) * sizeof(char));
strcpy(*username, submittedUsername);
-
const char* submittedPassword = [dialog.password cStringUsingEncoding:
NSUTF8StringEncoding];
*password = malloc((strlen(submittedPassword) + 1) * sizeof(char));
strcpy(*password, submittedPassword);
-
const char* submittedDomain = [dialog.domain cStringUsingEncoding:
- NSUTF8StringEncoding];
+ NSUTF8StringEncoding];
*domain = malloc((strlen(submittedDomain) + 1) * sizeof(char));
strcpy(*domain, submittedDomain);
}
#import "PasswordDialog.h"
#import <freerdp/client/cmdline.h>
-@interface PasswordDialog ()
+@interface PasswordDialog()
-@property BOOL modalCode;
+ @property BOOL modalCode;
@end
[super windowDidLoad];
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
[self.window setTitle:self.serverHostname];
- [messageLabel setStringValue:[NSString stringWithFormat:@"Authenticate to %@", self.serverHostname]];
-
+ [messageLabel setStringValue:[NSString stringWithFormat:@"Authenticate to %@",
+ self.serverHostname]];
NSMutableString* domainUser = [[NSMutableString alloc] initWithString:@""];
- if (self.domain != nil && [[self.domain stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length] > 0)
+ if (self.domain != nil
+ && [[self.domain stringByTrimmingCharactersInSet:[NSCharacterSet
+ whitespaceCharacterSet]] length] > 0)
{
[domainUser appendFormat:@"%@\\", self.domain];
}
[domainUser appendString:self.username];
[self.window makeFirstResponder:passwordText];
}
+
[usernameText setStringValue:domainUser];
}
-- (IBAction)onOK:(NSObject *)sender
+- (IBAction)onOK:(NSObject*)sender
{
- char *submittedUser = NULL;
- char *submittedDomain = NULL;
+ char* submittedUser = NULL;
+ char* submittedDomain = NULL;
- if (freerdp_parse_username([self.usernameText.stringValue cStringUsingEncoding:NSUTF8StringEncoding], &submittedUser, &submittedDomain)) {
- self.username = [NSString stringWithCString: submittedUser encoding:NSUTF8StringEncoding];
- self.domain = [NSString stringWithCString: submittedDomain encoding:NSUTF8StringEncoding];
- } else {
+ if (freerdp_parse_username([self.usernameText.stringValue cStringUsingEncoding:
+ NSUTF8StringEncoding], &submittedUser, &submittedDomain))
+ {
+ self.username = [NSString stringWithCString: submittedUser encoding:
+ NSUTF8StringEncoding];
+ self.domain = [NSString stringWithCString: submittedDomain encoding:
+ NSUTF8StringEncoding];
+ }
+ else
+ {
self.username = self.usernameText.stringValue;
}
[NSApp stopModalWithCode:TRUE];
}
-- (IBAction)onCancel:(NSObject *)sender
+- (IBAction)onCancel:(NSObject*)sender
{
[NSApp stopModalWithCode:FALSE];
}
- (BOOL)runModal:(NSWindow*)mainWindow
{
- if ([mainWindow respondsToSelector:@selector(beginSheet:completionHandler:)]) {
-
+ if ([mainWindow respondsToSelector:@selector(beginSheet:completionHandler:)])
+ {
[mainWindow beginSheet:self.window completionHandler:nil];
-
self.modalCode = [NSApp runModalForWindow: self.window];
[mainWindow endSheet: self.window];
-
- } else {
+ }
+ else
+ {
[NSApp beginSheet: self.window
- modalForWindow: mainWindow
- modalDelegate: nil
- didEndSelector: nil
- contextInfo: nil];
-
+ modalForWindow: mainWindow
+ modalDelegate: nil
+ didEndSelector: nil
+ contextInfo: nil];
self.modalCode = [NSApp runModalForWindow: self.window];
[NSApp endSheet: self.window];
}
[self.window orderOut:nil];
-
return self.modalCode;
}
[username release];
[password release];
[domain release];
-
[super dealloc];
}
#import <freerdp/client/cmdline.h>
static AppDelegate* _singleDelegate = nil;
-void AppDelegate_ConnectionResultEventHandler(void* context, ConnectionResultEventArgs* e);
+void AppDelegate_ConnectionResultEventHandler(void* context,
+ ConnectionResultEventArgs* e);
void AppDelegate_ErrorInfoEventHandler(void* ctx, ErrorInfoEventArgs* e);
-void AppDelegate_EmbedWindowEventHandler(void* context, EmbedWindowEventArgs* e);
-void AppDelegate_ResizeWindowEventHandler(void* context, ResizeWindowEventArgs* e);
+void AppDelegate_EmbedWindowEventHandler(void* context,
+ EmbedWindowEventArgs* e);
+void AppDelegate_ResizeWindowEventHandler(void* context,
+ ResizeWindowEventArgs* e);
void mac_set_view_size(rdpContext* context, MRDPView* view);
@implementation AppDelegate
{
int status;
mfContext* mfc;
-
_singleDelegate = self;
[self CreateContext];
-
status = [self ParseCommandLineArguments];
-
mfc = (mfContext*) context;
mfc->view = (void*) mrdpView;
if (status < 0)
{
- NSString *winTitle;
+ NSString* winTitle;
winTitle = [[NSString alloc] initWithCString:"ERROR"];
-
[window setTitle:winTitle];
-
}
else
{
context->instance->settings->DesktopHeight = screenFrame.size.height;
}
- PubSub_SubscribeConnectionResult(context->pubSub, AppDelegate_ConnectionResultEventHandler);
+ PubSub_SubscribeConnectionResult(context->pubSub,
+ AppDelegate_ConnectionResultEventHandler);
PubSub_SubscribeErrorInfo(context->pubSub, AppDelegate_ErrorInfoEventHandler);
- PubSub_SubscribeEmbedWindow(context->pubSub, AppDelegate_EmbedWindowEventHandler);
- PubSub_SubscribeResizeWindow(context->pubSub, AppDelegate_ResizeWindowEventHandler);
-
+ PubSub_SubscribeEmbedWindow(context->pubSub,
+ AppDelegate_EmbedWindowEventHandler);
+ PubSub_SubscribeResizeWindow(context->pubSub,
+ AppDelegate_ResizeWindowEventHandler);
freerdp_client_start(context);
+ NSString* winTitle;
- NSString *winTitle;
- if ( mfc->context.settings->WindowTitle && mfc->context.settings->WindowTitle[0])
+ if (mfc->context.settings->WindowTitle && mfc->context.settings->WindowTitle[0])
{
- winTitle = [[NSString alloc] initWithCString:mfc->context.settings->WindowTitle];
+ winTitle = [[NSString alloc] initWithCString:
+ mfc->context.settings->WindowTitle];
}
else
{
- winTitle = [[NSString alloc] initWithFormat:@"%@:%u",
- [NSString stringWithCString:mfc->context.settings->ServerHostname encoding:NSUTF8StringEncoding],
- mfc->context.settings->ServerPort];
+ winTitle = [[NSString alloc] initWithFormat:@"%@:%u",
+ [NSString stringWithCString:mfc->context.settings->ServerHostname encoding:
+ NSUTF8StringEncoding],
+ mfc->context.settings->ServerPort];
}
[window setTitle:winTitle];
{
NSLog(@"Stopping...\n");
freerdp_client_stop(context);
-
[mrdpView releaseResources];
_singleDelegate = nil;
-
NSLog(@"Stopped.\n");
}
-- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
+- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)sender
{
return YES;
}
int length;
int status;
char* cptr;
-
NSArray* args = [[NSProcessInfo processInfo] arguments];
-
context->argc = (int) [args count];
context->argv = malloc(sizeof(char*) * context->argc);
-
i = 0;
-
- for (NSString* str in args)
+
+ for (NSString * str in args)
{
/* filter out some arguments added by XCode */
-
if ([str isEqualToString:@"YES"])
continue;
-
+
if ([str isEqualToString:@"-NSDocumentRevisionsDebugMode"])
continue;
-
- length = (int) ([str length] + 1);
+
+ length = (int)([str length] + 1);
cptr = (char*) malloc(length);
strcpy(cptr, [str UTF8String]);
context->argv[i++] = cptr;
}
-
- context->argc = i;
-
- status = freerdp_client_settings_parse_command_line(context->settings, context->argc, context->argv, FALSE);
-
- status = freerdp_client_settings_command_line_status_print(context->settings, status, context->argc, context->argv);
+ context->argc = i;
+ status = freerdp_client_settings_parse_command_line(context->settings,
+ context->argc, context->argv, FALSE);
+ status = freerdp_client_settings_command_line_status_print(context->settings,
+ status, context->argc, context->argv);
return status;
}
- (void) CreateContext
{
RDP_CLIENT_ENTRY_POINTS clientEntryPoints;
-
ZeroMemory(&clientEntryPoints, sizeof(RDP_CLIENT_ENTRY_POINTS));
clientEntryPoints.Size = sizeof(RDP_CLIENT_ENTRY_POINTS);
clientEntryPoints.Version = RDP_CLIENT_INTERFACE_VERSION;
-
RdpClientEntry(&clientEntryPoints);
-
context = freerdp_client_context_new(&clientEntryPoints);
}
{
mfContext* mfc;
MRDPView* view;
-
mfc = (mfContext*) context;
view = (MRDPView*) mfc->view;
-
[view exitFullScreenModeWithOptions:nil];
[view releaseResources];
[view release];
- mfc->view = nil;
-
+ mfc->view = nil;
freerdp_client_context_free(context);
context = nil;
}
{
mfContext* mfc;
MRDPView* view;
-
mfc = (mfContext*) context;
view = (MRDPView*) mfc->view;
-
[view exitFullScreenModeWithOptions:nil];
-
NSString* message = withMessage ? withMessage : @"Error connecting to server";
-
- NSAlert *alert = [[NSAlert alloc] init];
+ NSAlert* alert = [[NSAlert alloc] init];
[alert setMessageText:message];
[alert beginSheetModalForWindow:[self window]
- modalDelegate:self
- didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
- contextInfo:nil];
+ modalDelegate:self
+ didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
+ contextInfo:nil];
}
* just a terminate selector for above call
***********************************************************************/
-- (void) alertDidEnd:(NSAlert *)a returnCode:(NSInteger)rc contextInfo:(void *)ci
+- (void) alertDidEnd:(NSAlert*)a returnCode:(NSInteger)rc contextInfo:(void*)ci
{
[NSApp terminate:nil];
}
* On connection error, display message and quit application
***********************************************************************/
-void AppDelegate_ConnectionResultEventHandler(void* ctx, ConnectionResultEventArgs* e)
+void AppDelegate_ConnectionResultEventHandler(void* ctx,
+ ConnectionResultEventArgs* e)
{
NSLog(@"ConnectionResult event result:%d\n", e->result);
+
if (_singleDelegate)
{
if (e->result != 0)
{
NSString* message = nil;
+
if (connectErrorCode == AUTHENTICATIONERROR)
{
- message = [NSString stringWithFormat:@"%@", @"Authentication failure, check credentials."];
+ message = [NSString stringWithFormat:@"%@",
+ @"Authentication failure, check credentials."];
}
-
-
+
// Making sure this should be invoked on the main UI thread.
- [_singleDelegate performSelectorOnMainThread:@selector(rdpConnectError:) withObject:message waitUntilDone:FALSE];
+ [_singleDelegate performSelectorOnMainThread:@selector(rdpConnectError:)
+ withObject:message waitUntilDone:FALSE];
}
}
}
void AppDelegate_ErrorInfoEventHandler(void* ctx, ErrorInfoEventArgs* e)
{
NSLog(@"ErrorInfo event code:%d\n", e->code);
+
if (_singleDelegate)
{
// Retrieve error message associated with error code
NSString* message = nil;
+
if (e->code != ERRINFO_NONE)
{
const char* errorMessage = freerdp_get_error_info_string(e->code);
message = [[NSString alloc] initWithUTF8String:errorMessage];
}
-
+
// Making sure this should be invoked on the main UI thread.
- [_singleDelegate performSelectorOnMainThread:@selector(rdpConnectError:) withObject:message waitUntilDone:TRUE];
+ [_singleDelegate performSelectorOnMainThread:@selector(rdpConnectError:)
+ withObject:message waitUntilDone:TRUE];
[message release];
}
}
void AppDelegate_EmbedWindowEventHandler(void* ctx, EmbedWindowEventArgs* e)
{
rdpContext* context = (rdpContext*) ctx;
-
+
if (_singleDelegate)
{
mfContext* mfc = (mfContext*) context;
_singleDelegate->mrdpView = mfc->view;
-
+
if (_singleDelegate->window)
{
[[_singleDelegate->window contentView] addSubview:mfc->view];
}
-
+
mac_set_view_size(context, mfc->view);
}
}
void AppDelegate_ResizeWindowEventHandler(void* ctx, ResizeWindowEventArgs* e)
{
rdpContext* context = (rdpContext*) ctx;
-
fprintf(stderr, "ResizeWindowEventHandler: %d %d\n", e->width, e->height);
-
+
if (_singleDelegate)
{
mfContext* mfc = (mfContext*) context;
innerRect.size.width = context->settings->DesktopWidth;
innerRect.size.height = context->settings->DesktopHeight;
[view setFrame:innerRect];
-
// calculate window of same size, but keep position
NSRect outerRect = [[view window] frame];
outerRect.size = [[view window] frameRectForContentRect:innerRect].size;
-
// we are not in RemoteApp mode, disable larger than resolution
[[view window] setContentMaxSize:innerRect.size];
-
// set window to given area
[[view window] setFrame:outerRect display:YES];
-
+
if (context->settings->Fullscreen)
[[view window] toggleFullScreen:nil];
}