mfreerdp: cleanup PasswordDialog

This commit is contained in:
Christian Hofstaedtler 2013-03-11 19:59:50 +01:00
parent 0f3c623299
commit a55cf4b3b1
4 changed files with 124 additions and 54 deletions

View File

@ -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);

View File

@ -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 <Cocoa/Cocoa.h>
@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;

View File

@ -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

View File

@ -57,6 +57,7 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{46, 127}, {108, 17}}</string>
<reference key="NSSuperview" ref="1006"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="605731100"/>
<string key="NSReuseIdentifierKey">_NS:1535</string>
<bool key="NSEnabled">YES</bool>
@ -97,6 +98,7 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{159, 124}, {233, 22}}</string>
<reference key="NSSuperview" ref="1006"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="215486301"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
@ -135,6 +137,7 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{46, 206}, {346, 17}}</string>
<reference key="NSSuperview" ref="1006"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="543773298"/>
<string key="NSReuseIdentifierKey">_NS:1535</string>
<bool key="NSEnabled">YES</bool>
@ -156,7 +159,7 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{384, 13}, {82, 32}}</string>
<reference key="NSSuperview" ref="1006"/>
<reference key="NSNextKeyView"/>
<reference key="NSWindow"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="588218063">
@ -180,6 +183,7 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{302, 13}, {82, 32}}</string>
<reference key="NSSuperview" ref="1006"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="732279407"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
@ -205,6 +209,7 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{46, 158}, {108, 17}}</string>
<reference key="NSSuperview" ref="1006"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="385178766"/>
<string key="NSReuseIdentifierKey">_NS:1535</string>
<bool key="NSEnabled">YES</bool>
@ -225,6 +230,7 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{159, 156}, {233, 22}}</string>
<reference key="NSSuperview" ref="1006"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="534466844"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
@ -245,6 +251,7 @@
</array>
<string key="NSFrameSize">{480, 270}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="677587178"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
@ -302,14 +309,6 @@
</object>
<int key="connectionID">52</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">userNameText</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="385178766"/>
</object>
<int key="connectionID">53</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
@ -964,9 +963,53 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">53</int>
<int key="maxID">54</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">PasswordDialog</string>
<string key="superclassName">NSWindowController</string>
<dictionary class="NSMutableDictionary" key="actions">
<string key="onCancel:">NSObject</string>
<string key="onOK:">NSObject</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="actionInfosByName">
<object class="IBActionInfo" key="onCancel:">
<string key="name">onCancel:</string>
<string key="candidateClassName">NSObject</string>
</object>
<object class="IBActionInfo" key="onOK:">
<string key="name">onOK:</string>
<string key="candidateClassName">NSObject</string>
</object>
</dictionary>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="messageLabel">NSTextField</string>
<string key="passwordText">NSTextField</string>
<string key="usernameText">NSTextField</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
<object class="IBToOneOutletInfo" key="messageLabel">
<string key="name">messageLabel</string>
<string key="candidateClassName">NSTextField</string>
</object>
<object class="IBToOneOutletInfo" key="passwordText">
<string key="name">passwordText</string>
<string key="candidateClassName">NSTextField</string>
</object>
<object class="IBToOneOutletInfo" key="usernameText">
<string key="name">usernameText</string>
<string key="candidateClassName">NSTextField</string>
</object>
</dictionary>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/PasswordDialog.h</string>
</object>
</object>
</array>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes"/>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>