20 #import "PasswordDialog.h"
21 #import <freerdp/client/cmdline.h>
23 #import <CoreGraphics/CoreGraphics.h>
27 @property BOOL modalCode;
33 @synthesize usernameText;
34 @synthesize passwordText;
35 @synthesize messageLabel;
36 @synthesize serverHostname;
40 @synthesize modalCode;
44 return [
self initWithWindowNibName:@"PasswordDialog"];
49 [
super windowDidLoad];
52 [
self.window setTitle:self.serverHostname];
54 setStringValue:[NSString stringWithFormat:@"Authenticate to %@", self.serverHostname]];
55 NSMutableString *domainUser = [[NSMutableString alloc] initWithString:@""];
57 if (
self.domain != nil &&
58 [[
self.domain stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]
61 [domainUser appendFormat:@"%@\\", self.domain];
64 if (
self.username != nil)
66 [domainUser appendString:self.username];
67 [
self.window makeFirstResponder:self.passwordText];
70 [
self.usernameText setStringValue:domainUser];
73 - (IBAction)onOK:(NSObject *)sender
75 char *submittedUser = NULL;
76 char *submittedDomain = NULL;
78 if (freerdp_parse_username(
79 [
self.usernameText.stringValue cStringUsingEncoding:NSUTF8StringEncoding],
80 &submittedUser, &submittedDomain))
83 self.username = [NSString stringWithCString:submittedUser
84 encoding:NSUTF8StringEncoding];
86 self.domain = [NSString stringWithCString:submittedDomain
87 encoding:NSUTF8StringEncoding];
91 self.username =
self.usernameText.stringValue;
94 self.password =
self.passwordText.stringValue;
96 free(submittedDomain);
97 [NSApp stopModalWithCode:TRUE];
100 - (IBAction)onCancel:(NSObject *)sender
102 [NSApp stopModalWithCode:FALSE];
105 - (BOOL)runModal:(NSWindow *)mainWindow
107 if ([mainWindow respondsToSelector:
@selector(beginSheet:completionHandler:)])
109 [mainWindow beginSheet:self.window completionHandler:nil];
110 self.modalCode = [NSApp runModalForWindow:self.window];
111 [mainWindow endSheet:self.window];
115 [NSApp beginSheet:self.window
116 modalForWindow:mainWindow
120 self.modalCode = [NSApp runModalForWindow:self.window];
121 [NSApp endSheet:self.window];
124 [
self.window orderOut:nil];
125 return self.modalCode;
130 [usernameText release];
131 [passwordText release];
132 [messageLabel release];
133 [serverHostname release];