From a55cf4b3b16e1278ae768d9b6346659ca471c29b Mon Sep 17 00:00:00 2001 From: Christian Hofstaedtler Date: Mon, 11 Mar 2013 19:59:50 +0100 Subject: [PATCH] mfreerdp: cleanup PasswordDialog --- client/Mac/MRDPView.m | 6 +-- client/Mac/PasswordDialog.h | 31 +++++++++----- client/Mac/PasswordDialog.m | 76 +++++++++++++++++++++-------------- client/Mac/PasswordDialog.xib | 65 +++++++++++++++++++++++++----- 4 files changed, 124 insertions(+), 54 deletions(-) diff --git a/client/Mac/MRDPView.m b/client/Mac/MRDPView.m index d0d1fc19d..66df776a6 100644 --- a/client/Mac/MRDPView.m +++ b/client/Mac/MRDPView.m @@ -1062,10 +1062,10 @@ BOOL mac_authenticate(freerdp* instance, char** username, char** password, char* { PasswordDialog* dialog = [PasswordDialog new]; - dialog.serverName = [NSString stringWithCString:instance->settings->ServerHostname encoding:NSUTF8StringEncoding]; + dialog.serverHostname = [NSString stringWithCString:instance->settings->ServerHostname encoding:NSUTF8StringEncoding]; if (*username) - dialog.userName = [NSString stringWithCString:*username encoding:NSUTF8StringEncoding]; + dialog.username = [NSString stringWithCString:*username encoding:NSUTF8StringEncoding]; if (*password) dialog.password = [NSString stringWithCString:*password encoding:NSUTF8StringEncoding]; @@ -1074,7 +1074,7 @@ BOOL mac_authenticate(freerdp* instance, char** username, char** password, char* if (ok) { - const char* submittedUsername = [dialog.userName cStringUsingEncoding:NSUTF8StringEncoding]; + const char* submittedUsername = [dialog.username cStringUsingEncoding:NSUTF8StringEncoding]; *username = malloc((strlen(submittedUsername) + 1) * sizeof(char)); strcpy(*username, submittedUsername); diff --git a/client/Mac/PasswordDialog.h b/client/Mac/PasswordDialog.h index db294d667..d95783ab2 100644 --- a/client/Mac/PasswordDialog.h +++ b/client/Mac/PasswordDialog.h @@ -1,24 +1,35 @@ -// -// PasswordDialog.h -// FreeRDP -// -// Created by Christian Hofstaedtler on 3/10/13. -// -// +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * MacFreeRDP + * + * Copyright 2013 Christian Hofstaedtler + * + * 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 @interface PasswordDialog : NSWindowController -@property (retain) IBOutlet NSTextField* userNameText; +@property (retain) IBOutlet NSTextField* usernameText; @property (retain) IBOutlet NSTextField* passwordText; @property (retain) IBOutlet NSTextField* messageLabel; - (IBAction)onOK:(NSObject*)sender; - (IBAction)onCancel:(NSObject*)sender; -@property (retain) NSString* serverName; -@property (retain) NSString* userName; +@property (retain) NSString* serverHostname; +@property (retain) NSString* username; @property (retain) NSString* password; - (BOOL) runModal; diff --git a/client/Mac/PasswordDialog.m b/client/Mac/PasswordDialog.m index 757ee0732..6c91cb2f6 100644 --- a/client/Mac/PasswordDialog.m +++ b/client/Mac/PasswordDialog.m @@ -1,10 +1,21 @@ -// -// PasswordDialog.m -// FreeRDP -// -// Created by Christian Hofstaedtler on 3/10/13. -// -// +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * MacFreeRDP + * + * Copyright 2013 Christian Hofstaedtler + * + * 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 "PasswordDialog.h" @@ -14,43 +25,48 @@ @implementation PasswordDialog -@synthesize userNameText; +@synthesize usernameText; @synthesize passwordText; @synthesize messageLabel; -@synthesize serverName; -@synthesize userName; +@synthesize serverHostname; +@synthesize username; @synthesize password; -- (id)init { - return [self initWithWindowNibName:@"PasswordDialog"]; +- (id)init +{ + return [self initWithWindowNibName:@"PasswordDialog"]; } - (void)windowDidLoad { - [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.serverName]; - [messageLabel setStringValue:[NSString stringWithFormat:@"Authenticate to %@", self.serverName]]; - if (self.userName != nil) { - [userNameText setStringValue:self.userName]; - [self.window makeFirstResponder:passwordText]; - } + [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]]; + if (self.username != nil) + { + [usernameText setStringValue:self.username]; + [self.window makeFirstResponder:passwordText]; + } } -- (IBAction)onOK:(NSObject *)sender { - self.userName = self.userNameText.stringValue; - self.password = self.passwordText.stringValue; - [self.window orderOut:nil]; - [NSApp stopModalWithCode:TRUE]; +- (IBAction)onOK:(NSObject *)sender +{ + 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]; +- (IBAction)onCancel:(NSObject *)sender +{ + [self.window orderOut:nil]; + [NSApp stopModalWithCode:FALSE]; } -- (BOOL) runModal { - return [NSApp runModalForWindow:self.window]; +- (BOOL)runModal +{ + return [NSApp runModalForWindow:self.window]; } @end diff --git a/client/Mac/PasswordDialog.xib b/client/Mac/PasswordDialog.xib index 3e1e08673..5d98e2a7a 100644 --- a/client/Mac/PasswordDialog.xib +++ b/client/Mac/PasswordDialog.xib @@ -57,6 +57,7 @@ 268 {{46, 127}, {108, 17}} + _NS:1535 YES @@ -97,6 +98,7 @@ 268 {{159, 124}, {233, 22}} + _NS:9 YES @@ -135,6 +137,7 @@ 268 {{46, 206}, {346, 17}} + _NS:1535 YES @@ -156,7 +159,7 @@ 268 {{384, 13}, {82, 32}} - + _NS:9 YES @@ -180,6 +183,7 @@ 268 {{302, 13}, {82, 32}} + _NS:9 YES @@ -205,6 +209,7 @@ 268 {{46, 158}, {108, 17}} + _NS:1535 YES @@ -225,6 +230,7 @@ 268 {{159, 156}, {233, 22}} + _NS:9 YES @@ -245,6 +251,7 @@ {480, 270} + {{0, 0}, {1440, 878}} @@ -302,14 +309,6 @@ 52 - - - userNameText - - - - 53 - delegate @@ -964,9 +963,53 @@ - 53 + 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