Commits

dergraf83  committed ec185b3

Changed CreateAccountWindowController to directly store the new settings in an Account object

  • Participants
  • Parent commits 295bcd7

Comments (0)

Files changed (3)

File English.lproj/CreateAccountWindow.xib

 		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
 			<bool key="EncodedWithXMLCoder">YES</bool>
 			<integer value="10"/>
-			<integer value="2"/>
+			<integer value="3"/>
 		</object>
 		<object class="NSArray" key="IBDocument.PluginDependencies">
 			<bool key="EncodedWithXMLCoder">YES</bool>
 												<string>-∞</string>
 												<string/>
 												<string/>
-												<integer value="1"/>
+												<integer value="0"/>
 												<string>+∞</string>
 												<integer value="4"/>
 												<boolean value="NO"/>
 											</object>
 										</object>
-										<string key="NS.positiveformat">#0</string>
-										<string key="NS.negativeformat">#0</string>
+										<string key="NS.positiveformat">#</string>
+										<string key="NS.negativeformat">#</string>
 										<nil key="NS.positiveattrs"/>
 										<nil key="NS.negativeattrs"/>
 										<nil key="NS.zero"/>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBBindingConnection" key="connection">
-						<string key="label">value: email</string>
-						<reference key="source" ref="292713335"/>
-						<reference key="destination" ref="1001"/>
-						<object class="NSNibBindingConnector" key="connector">
-							<reference key="NSSource" ref="292713335"/>
-							<reference key="NSDestination" ref="1001"/>
-							<string key="NSLabel">value: email</string>
-							<string key="NSBinding">value</string>
-							<string key="NSKeyPath">email</string>
-							<int key="NSNibBindingConnectorVersion">2</int>
-						</object>
-					</object>
-					<int key="connectionID">54</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBBindingConnection" key="connection">
-						<string key="label">value: serverName</string>
-						<reference key="source" ref="1062926212"/>
-						<reference key="destination" ref="1001"/>
-						<object class="NSNibBindingConnector" key="connector">
-							<reference key="NSSource" ref="1062926212"/>
-							<reference key="NSDestination" ref="1001"/>
-							<string key="NSLabel">value: serverName</string>
-							<string key="NSBinding">value</string>
-							<string key="NSKeyPath">serverName</string>
-							<int key="NSNibBindingConnectorVersion">2</int>
-						</object>
-					</object>
-					<int key="connectionID">55</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBBindingConnection" key="connection">
-						<string key="label">value: userName</string>
-						<reference key="source" ref="887949807"/>
-						<reference key="destination" ref="1001"/>
-						<object class="NSNibBindingConnector" key="connector">
-							<reference key="NSSource" ref="887949807"/>
-							<reference key="NSDestination" ref="1001"/>
-							<string key="NSLabel">value: userName</string>
-							<string key="NSBinding">value</string>
-							<string key="NSKeyPath">userName</string>
-							<int key="NSNibBindingConnectorVersion">2</int>
-						</object>
-					</object>
-					<int key="connectionID">56</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBBindingConnection" key="connection">
 						<string key="label">value: password</string>
 						<reference key="source" ref="972146351"/>
 						<reference key="destination" ref="1001"/>
 					<int key="connectionID">62</int>
 				</object>
 				<object class="IBConnectionRecord">
-					<object class="IBBindingConnection" key="connection">
-						<string key="label">value: port</string>
-						<reference key="source" ref="277134734"/>
-						<reference key="destination" ref="1001"/>
-						<object class="NSNibBindingConnector" key="connector">
-							<reference key="NSSource" ref="277134734"/>
-							<reference key="NSDestination" ref="1001"/>
-							<string key="NSLabel">value: port</string>
-							<string key="NSBinding">value</string>
-							<string key="NSKeyPath">port</string>
-							<int key="NSNibBindingConnectorVersion">2</int>
-						</object>
-					</object>
-					<int key="connectionID">70</int>
-				</object>
-				<object class="IBConnectionRecord">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">switchToAdvancedView:</string>
 						<reference key="source" ref="1001"/>
 					<int key="connectionID">73</int>
 				</object>
 				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">advancedButton</string>
-						<reference key="source" ref="1001"/>
-						<reference key="destination" ref="634093929"/>
-					</object>
-					<int key="connectionID">74</int>
-				</object>
-				<object class="IBConnectionRecord">
 					<object class="IBBindingConnection" key="connection">
 						<string key="label">enabled: canInteract</string>
 						<reference key="source" ref="634093929"/>
 					</object>
 					<int key="connectionID">82</int>
 				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBBindingConnection" key="connection">
+						<string key="label">value: account.host</string>
+						<reference key="source" ref="1062926212"/>
+						<reference key="destination" ref="1001"/>
+						<object class="NSNibBindingConnector" key="connector">
+							<reference key="NSSource" ref="1062926212"/>
+							<reference key="NSDestination" ref="1001"/>
+							<string key="NSLabel">value: account.host</string>
+							<string key="NSBinding">value</string>
+							<string key="NSKeyPath">account.host</string>
+							<int key="NSNibBindingConnectorVersion">2</int>
+						</object>
+					</object>
+					<int key="connectionID">84</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBBindingConnection" key="connection">
+						<string key="label">value: account.port</string>
+						<reference key="source" ref="277134734"/>
+						<reference key="destination" ref="1001"/>
+						<object class="NSNibBindingConnector" key="connector">
+							<reference key="NSSource" ref="277134734"/>
+							<reference key="NSDestination" ref="1001"/>
+							<string key="NSLabel">value: account.port</string>
+							<string key="NSBinding">value</string>
+							<string key="NSKeyPath">account.port</string>
+							<int key="NSNibBindingConnectorVersion">2</int>
+						</object>
+					</object>
+					<int key="connectionID">85</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBBindingConnection" key="connection">
+						<string key="label">value: account.user</string>
+						<reference key="source" ref="887949807"/>
+						<reference key="destination" ref="1001"/>
+						<object class="NSNibBindingConnector" key="connector">
+							<reference key="NSSource" ref="887949807"/>
+							<reference key="NSDestination" ref="1001"/>
+							<string key="NSLabel">value: account.user</string>
+							<string key="NSBinding">value</string>
+							<string key="NSKeyPath">account.user</string>
+							<int key="NSNibBindingConnectorVersion">2</int>
+						</object>
+					</object>
+					<int key="connectionID">86</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBBindingConnection" key="connection">
+						<string key="label">value: account.accountName</string>
+						<reference key="source" ref="292713335"/>
+						<reference key="destination" ref="1001"/>
+						<object class="NSNibBindingConnector" key="connector">
+							<reference key="NSSource" ref="292713335"/>
+							<reference key="NSDestination" ref="1001"/>
+							<string key="NSLabel">value: account.accountName</string>
+							<string key="NSBinding">value</string>
+							<string key="NSKeyPath">account.accountName</string>
+							<int key="NSNibBindingConnectorVersion">2</int>
+						</object>
+					</object>
+					<int key="connectionID">87</int>
+				</object>
 			</object>
 			<object class="IBMutableOrderedSet" key="objectRecords">
 				<object class="NSArray" key="orderedObjects">
 							<reference ref="153428260"/>
 							<reference ref="699460670"/>
 							<reference ref="510162421"/>
-							<reference ref="520639836"/>
 							<reference ref="34523630"/>
 							<reference ref="634093929"/>
+							<reference ref="520639836"/>
 						</object>
 						<reference key="parent" ref="1006"/>
 					</object>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<integer value="1040"/>
 					<boolean value="YES"/>
-					<real value="955555"/>
+					<real value="2000"/>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 				</object>
 			</object>
 			<nil key="sourceID"/>
-			<int key="maxID">82</int>
+			<int key="maxID">87</int>
 		</object>
 		<object class="IBClassDescriber" key="IBDocument.Classes">
 			<object class="NSMutableArray" key="referencedPartialClassDescriptions">

File Source/CreateAccountWindowController.h

 #import <Cocoa/Cocoa.h>
 
 #import "SieveClient.h"
+@class Account;
 
 extern NSString * const kAppErrorDomain;
 enum {
     BOOL savePassword;
     NSString *email;
     NSString *password;
-    NSString *userName;
-    NSString *serverName;
-    unsigned port;
+    
+    Account *account;
     
     BOOL triedAuth;
     BOOL canInteract;
 @property (assign, readwrite) BOOL savePassword;
 @property (copy, readwrite) NSString *email;
 @property (copy, readwrite) NSString *password;
-@property (copy, readwrite) NSString *userName;
-@property (copy, readwrite) NSString *serverName;
-@property (assign, readwrite) unsigned port;
+@property (retain, readwrite) Account *account;
 
 @property (assign, readwrite) BOOL canInteract;
 

File Source/CreateAccountWindowController.m

 
 #import "CreateAccountWindowController.h"
 #import "ServiceLookup.h"
+#import "Account.h"
 
 NSString * const kAppErrorDomain = @"AppErrorDomain";
 
 @implementation CreateAccountWindowController
 
 @synthesize savePassword;
-@synthesize serverName;
 @synthesize email;
 @synthesize password;
-@synthesize userName;
-@synthesize port;
+@synthesize account;
 @synthesize canInteract;
 
 - (void) run;
 - init;
 {
     self =  [super initWithWindowNibName: @"CreateAccountWindow"];
+
+    [self setAccount:  [[[Account alloc] init] autorelease]];
     
     savePassword = YES;
-    port = 2000;
     canInteract = YES;
     
     return self;
     }
 }
 
+- (void) setEmail: (NSString *)newEmail;
+{
+    if (email != newEmail) {
+        [email release];
+        email = [newEmail copy];
+        [account setAccountName: email];
+    }
+}
+
 - (void) beginChecks;
 {
     if (showsAdvancedView) {
     NSRange range = [email rangeOfString: @"@"];
     NSAssert( range.location != NSNotFound, @"Validation means there has to be a @" );
     
-    [self setUserName: [email substringToIndex: range.location]];
-    [self setServerName: [email substringFromIndex: range.location + 1]];
+    [account setUser: [email substringToIndex: range.location]];
+    [account setHost: [email substringFromIndex: range.location + 1]];
     
     [spinner setHidden:  NO];
     [spinner startAnimation: self];
     [statusText setHidden: NO];
     [statusText setStringValue: NSLocalizedString( @"Looking up host name", @"" )];
     
-    ServiceLookup *lookup = [[ServiceLookup alloc] initWithServiceName: [NSString stringWithFormat: @"_sieve._tcp.%@", serverName]];
+    ServiceLookup *lookup = [[ServiceLookup alloc] initWithServiceName: [NSString stringWithFormat: @"_sieve._tcp.%@", [account host]]];
     [lookup setTimeout: [[NSUserDefaults standardUserDefaults] floatForKey: @"srvLookupTimeout"]];
     
     [lookup lookupWithBlock: ^{
             
             // TODO: figure out, which has the highest priority/weight
             NSDictionary *item = [result objectAtIndex: 0];
-            [self setServerName: [item valueForKey: kServiceLookupHostKey]];
-            [self setPort:  [[item valueForKey: kServiceLookupPortKey] unsignedIntValue]];
+            [account setHost: [item valueForKey: kServiceLookupHostKey]];
+            [account setPort:  [[item valueForKey: kServiceLookupPortKey] unsignedIntValue]];
         }
         [self checkConnection];
         [lookup release];
     SieveClient *client = [[SieveClient alloc] init];
     [client setDelegate: self];
     
-    [client connectToHost: serverName port: port];
+    [client connectToHost: [account host] port: [account port]];
 }
 
 
         [client release];
         [self switchToAdvancedView: self];
     } else {
-        NSURLCredential *creds = [NSURLCredential credentialWithUser: userName password: password persistence: NSURLCredentialPersistenceNone];
+        NSURLCredential *creds = [NSURLCredential credentialWithUser: [account user] password: password persistence: NSURLCredentialPersistenceNone];
         triedAuth = YES;
         [client continueAuthWithCredentials: creds];
     }