[73317] users/ryandesign/PCLauncher/LoginWindowController.m

ryandesign at macports.org ryandesign at macports.org
Tue Nov 9 21:14:41 PST 2010


Revision: 73317
          http://trac.macports.org/changeset/73317
Author:   ryandesign at macports.org
Date:     2010-11-09 21:14:38 -0800 (Tue, 09 Nov 2010)
Log Message:
-----------
Read old-style login info when reading prefs; delete old-style login info when writing prefs

Modified Paths:
--------------
    users/ryandesign/PCLauncher/LoginWindowController.m

Modified: users/ryandesign/PCLauncher/LoginWindowController.m
===================================================================
--- users/ryandesign/PCLauncher/LoginWindowController.m	2010-11-10 05:10:31 UTC (rev 73316)
+++ users/ryandesign/PCLauncher/LoginWindowController.m	2010-11-10 05:14:38 UTC (rev 73317)
@@ -101,10 +101,22 @@
 	[currentServer showStatusInField:serverStatusLabel];
 	
 	NSDictionary *login = [[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"logins"] objectForKey:[currentServer internalName]];
-	[usernameField setStringValue:(login ? [login objectForKey:@"username"] : @"")];
-	NSString *password = (login ? [login objectForKey:@"password"] : @"");
+	NSString *username;
+	NSString *password;
+	if (login) {
+		username = [login objectForKey:@"username"];
+		password = [login objectForKey:@"password"];
+	} else if ([[currentServer internalName] isEqualToString:@"default"]) {
+		username = [[NSUserDefaults standardUserDefaults] objectForKey:@"username"];
+		password = [[NSUserDefaults standardUserDefaults] objectForKey:@"password"];
+	} else {
+		username = @"";
+		password = @"";
+	}
+	
+	[usernameField setStringValue:username];
 	[passwordField setStringValue:password];
-	[rememberPasswordCheckbox setState:(login ? ([password length] > 0) : NO)];
+	[rememberPasswordCheckbox setState:([password length] > 0)];
 	
 	[createAccountButton setEnabled:([currentServer createAccountUrl] != nil)];
 }
@@ -284,6 +296,9 @@
 	[logins setObject:login forKey:[currentServer internalName]];
 	
 	[[NSUserDefaults standardUserDefaults] setObject:logins forKey:@"logins"];
+	
+	[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"username"];
+	[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"password"];
 }
 
 - (IBAction)createAccountButtonClicked:(id)sender {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20101109/5166b37d/attachment.html>


More information about the macports-changes mailing list