diff --git a/client/Mac/MRDPView.m b/client/Mac/MRDPView.m index 0cb91bae8..48cfb2889 100644 --- a/client/Mac/MRDPView.m +++ b/client/Mac/MRDPView.m @@ -965,9 +965,13 @@ BOOL mac_post_connect(freerdp* instance) BOOL mac_authenticate(freerdp* instance, char** username, char** password, char** domain) { + mfContext* mfc = (mfContext*) instance->context; + MRDPView* view = (MRDPView*) mfc->view; + PasswordDialog* dialog = [PasswordDialog new]; - dialog.serverHostname = [NSString stringWithCString: - instance->settings->ServerHostname encoding:NSUTF8StringEncoding]; + dialog.serverHostname = [NSString stringWithFormat:@"%@:%u", + [NSString stringWithCString:instance->settings->ServerHostname encoding:NSUTF8StringEncoding], + instance->settings->ServerPort]; if (*username) dialog.username = [NSString stringWithCString:*username encoding: @@ -977,7 +981,11 @@ BOOL mac_authenticate(freerdp* instance, char** username, char** password, dialog.password = [NSString stringWithCString:*password encoding: NSUTF8StringEncoding]; - [dialog performSelectorOnMainThread:@selector(runModal) withObject:nil waitUntilDone:TRUE]; + if (*domain) + dialog.domain = [NSString stringWithCString:*domain encoding: + NSUTF8StringEncoding]; + + [dialog performSelectorOnMainThread:@selector(runModal:) withObject:[view window] waitUntilDone:TRUE]; BOOL ok = dialog.modalCode; @@ -987,10 +995,16 @@ BOOL mac_authenticate(freerdp* instance, char** username, char** password, 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]; + *domain = malloc((strlen(submittedDomain) + 1) * sizeof(char)); + strcpy(*domain, submittedDomain); } return ok; diff --git a/client/Mac/PasswordDialog.h b/client/Mac/PasswordDialog.h index 7c3999987..e7fb9b6b7 100644 --- a/client/Mac/PasswordDialog.h +++ b/client/Mac/PasswordDialog.h @@ -28,6 +28,7 @@ NSString* serverHostname; NSString* username; NSString* password; + NSString* domain; BOOL modalCode; } @property (retain) IBOutlet NSTextField* usernameText; @@ -40,8 +41,9 @@ @property (retain) NSString* serverHostname; @property (retain) NSString* username; @property (retain) NSString* password; -@property BOOL modalCode; +@property (retain) NSString* domain; +@property (readonly) BOOL modalCode; -- (BOOL) runModal; +- (BOOL) runModal:(NSWindow*)mainWindow; @end diff --git a/client/Mac/PasswordDialog.m b/client/Mac/PasswordDialog.m index e6e5ac142..37f4f1879 100644 --- a/client/Mac/PasswordDialog.m +++ b/client/Mac/PasswordDialog.m @@ -18,9 +18,12 @@ */ #import "PasswordDialog.h" +#import @interface PasswordDialog () +@property BOOL modalCode; + @end @implementation PasswordDialog @@ -31,6 +34,7 @@ @synthesize serverHostname; @synthesize username; @synthesize password; +@synthesize domain; @synthesize modalCode; - (id)init @@ -44,30 +48,66 @@ // 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]]; + + NSMutableString* domainUser = [[NSMutableString alloc] initWithString:@""]; + + if (self.domain != nil && [[self.domain stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length] > 0) + { + [domainUser appendFormat:@"%@\\", self.domain]; + } + if (self.username != nil) { - [usernameText setStringValue:self.username]; + [domainUser appendString:self.username]; [self.window makeFirstResponder:passwordText]; } + [usernameText setStringValue:domainUser]; } - (IBAction)onOK:(NSObject *)sender { - self.username = self.usernameText.stringValue; + 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 { + self.username = self.usernameText.stringValue; + } + self.password = self.passwordText.stringValue; - [self.window orderOut:nil]; [NSApp stopModalWithCode:TRUE]; } - (IBAction)onCancel:(NSObject *)sender { - [self.window orderOut:nil]; [NSApp stopModalWithCode:FALSE]; } -- (BOOL)runModal +- (BOOL)runModal:(NSWindow*)mainWindow { - return (self.modalCode = [NSApp runModalForWindow:self.window]); + if ([mainWindow respondsToSelector:@selector(beginSheet:completionHandler:)]) { + + [mainWindow beginSheet:self.window completionHandler:nil]; + + self.modalCode = [NSApp runModalForWindow: self.window]; + [mainWindow endSheet: self.window]; + + } else { + [NSApp beginSheet: self.window + 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; } - (void)dealloc @@ -78,6 +118,7 @@ [serverHostname release]; [username release]; [password release]; + [domain release]; [super dealloc]; } diff --git a/client/Mac/PasswordDialog.xib b/client/Mac/PasswordDialog.xib index afdd957c7..3911c14bd 100644 --- a/client/Mac/PasswordDialog.xib +++ b/client/Mac/PasswordDialog.xib @@ -1,1019 +1,132 @@ - - - 1080 - 12C60 - 3084 - 1187.34 - 625.00 - - com.apple.InterfaceBuilder.CocoaPlugin - 3084 - - - IBNSLayoutConstraint - NSButton - NSButtonCell - NSCustomObject - NSSecureTextField - NSSecureTextFieldCell - NSTextField - NSTextFieldCell - NSView - NSWindowTemplate - - - com.apple.InterfaceBuilder.CocoaPlugin - - - PluginDependencyRecalculationVersion - - - - - PasswordDialog - - - FirstResponder - - - NSApplication - - - 257 - 2 - {{196, 240}, {480, 270}} - 544735232 - Window - NSWindow - - - - - 256 - - - - 268 - {{46, 127}, {108, 17}} - - - - _NS:1535 - YES - - 68157504 - 272630784 - Password: - - LucidaGrande - 13 - 1044 - - _NS:1535 - - - 6 - System - controlColor - - 3 - MC42NjY2NjY2NjY3AA - - - - 6 - System - controlTextColor - - 3 - MAA - - - - NO - - - - 268 - {{159, 124}, {233, 22}} - - - - _NS:9 - YES - - 342884416 - 272630848 - - - Password - _NS:9 - - YES - - 6 - System - textBackgroundColor - - 3 - MQA - - - - 6 - System - textColor - - - - NSAllRomanInputSourcesLocaleIdentifier - - - NO - - - - 268 - {{46, 206}, {346, 17}} - - - - _NS:1535 - YES - - 68157504 - 272630784 - Connect to SERVER_NAME - - - _NS:1535 - - - - - NO - - - - 268 - {{384, 13}, {82, 32}} - - - _NS:9 - YES - - 67108864 - 134217728 - Cancel - - _NS:9 - - -2038284288 - 129 - - Gw - 200 - 25 - - NO - - - - 268 - {{302, 13}, {82, 32}} - - - - _NS:9 - YES - - 67108864 - 134217728 - OK - - _NS:9 - - -2038284288 - 129 - - - DQ - 200 - 25 - - NO - - - - 268 - {{46, 158}, {108, 17}} - - - - _NS:1535 - YES - - 68157504 - 272630784 - Username: - - _NS:1535 - - - - - NO - - - - 268 - {{159, 156}, {233, 22}} - - - - _NS:9 - YES - - -1804599231 - 272630784 - - - Username - _NS:9 - - YES - - - - NO - - - {480, 270} - - - - - {{0, 0}, {1440, 878}} - {10000000000000, 10000000000000} - YES - - - - - - - window - - - - 3 - - - - passwordText - - - - 48 - - - - usernameText - - - - 49 - - - - messageLabel - - - - 50 - - - - onOK: - - - - 51 - - - - onCancel: - - - - 52 - - - - delegate - - - - 4 - - - - - - 0 - - - - - - -2 - - - File's Owner - - - -1 - - - First Responder - - - -3 - - - Application - - - 1 - - - - - - - - 2 - - - - - 6 - 0 - - 6 - 1 - - 20 - - 1000 - - 8 - 29 - 3 - - - - 4 - 0 - - 4 - 1 - - 20 - - 1000 - - 8 - 29 - 3 - - - - 5 - 0 - - 6 - 1 - - 12 - - 1000 - - 6 - 24 - 3 - - - - 4 - 0 - - 4 - 1 - - 20 - - 1000 - - 8 - 29 - 3 - - - - 3 - 0 - - 4 - 1 - - 10 - - 1000 - - 6 - 24 - 3 - - - - 6 - 0 - - 6 - 1 - - 0.0 - - 1000 - - 6 - 24 - 2 - - - - 5 - 0 - - 6 - 1 - - 8 - - 1000 - - 6 - 24 - 3 - - - - 5 - 0 - - 5 - 1 - - 0.0 - - 1000 - - 6 - 24 - 2 - - - - 5 - 0 - - 6 - 1 - - 8 - - 1000 - - 6 - 24 - 3 - - - - 10 - 0 - - 10 - 1 - - 0.0 - - 1000 - - 5 - 22 - 2 - - - - 10 - 0 - - 10 - 1 - - 0.0 - - 1000 - - 6 - 24 - 2 - - - - 11 - 0 - - 11 - 1 - - 0.0 - - 1000 - - 6 - 24 - 2 - - - - 5 - 0 - - 5 - 1 - - 0.0 - - 1000 - - 6 - 24 - 2 - - - - 5 - 0 - - 5 - 1 - - 0.0 - - 1000 - - 6 - 24 - 2 - - - - 3 - 0 - - 3 - 1 - - 47 - - 1000 - - 3 - 9 - 3 - - - - 5 - 0 - - 5 - 1 - - 49 - - 1000 - - 3 - 9 - 3 - - - - - - - - - - - - - 5 - - - - - - - - 6 - - - - - - - - 7 - - - - - 7 - 0 - - 0 - 1 - - 340 - - 1000 - - 3 - 9 - 1 - - - - - - - 8 - - - - - - - - 9 - - - - - 7 - 0 - - 0 - 1 - - 70 - - 1000 - - 3 - 9 - 1 - - - - - - - 10 - - - - - 7 - 0 - - 0 - 1 - - 102 - - 1000 - - 3 - 9 - 1 - - - - - - - 11 - - - - - 7 - 0 - - 0 - 1 - - 233 - - 1000 - - 3 - 9 - 1 - - - - - - - 12 - - - - - 13 - - - - - 14 - - - - - 15 - - - - - 16 - - - - - 17 - - - - - 18 - - - - - 19 - - - - - 20 - - - - - 21 - - - - - 22 - - - - - 25 - - - - - 27 - - - - - 28 - - - - - 30 - - - - - 31 - - - - - 32 - - - - - 34 - - - - - 37 - - - - - 39 - - - - - 41 - - - - - 42 - - - - - 43 - - - - - 44 - - - - - 45 - - - - - 46 - - - - - 47 - - - - - - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - {{357, 418}, {480, 270}} - - - - - - com.apple.InterfaceBuilder.CocoaPlugin - - - - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - - - - - - - - - - - - - - - - - - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - - - - com.apple.InterfaceBuilder.CocoaPlugin - - com.apple.InterfaceBuilder.CocoaPlugin - - - - - com.apple.InterfaceBuilder.CocoaPlugin - - - - - - 54 - - - - - PasswordDialog - NSWindowController - - NSObject - NSObject - - - - onCancel: - NSObject - - - onOK: - NSObject - - - - NSTextField - NSTextField - NSTextField - - - - messageLabel - NSTextField - - - passwordText - NSTextField - - - usernameText - NSTextField - - - - IBProjectSource - ./Classes/PasswordDialog.h - - - - - 0 - IBCocoaFramework - YES - 3 - YES - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NSAllRomanInputSourcesLocaleIdentifier + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/client/Mac/cli/AppDelegate.m b/client/Mac/cli/AppDelegate.m index 677e522bf..4920c35f5 100644 --- a/client/Mac/cli/AppDelegate.m +++ b/client/Mac/cli/AppDelegate.m @@ -77,7 +77,9 @@ void mac_set_view_size(rdpContext* context, MRDPView* view); } else { - winTitle = [[NSString alloc] initWithCString:"FreeRDP"]; + winTitle = [[NSString alloc] initWithFormat:@"%@:%u", + [NSString stringWithCString:mfc->context.settings->ServerHostname encoding:NSUTF8StringEncoding], + mfc->context.settings->ServerPort]; } [window setTitle:winTitle];