+
+ if (!clientProxy) {
+ ITDebugLog(@"Null proxy! Couldn't connect!");
+ [self disconnect];
+ return NO;
+ }
+
+ if ([clientProxy requiresPassword]) {
+ ITDebugLog(@"Server requires password.");
+ //Check to see if a password is set in defaults
+ if ([[NSUserDefaults standardUserDefaults] dataForKey:@"connectPassword"] == nil) {
+ ITDebugLog(@"Asking for password.");
+ if (![[PreferencesController sharedPrefs] showPasswordPanel]) {
+ ITDebugLog(@"Giving up connection attempt.");
+ [self disconnect];
+ return -1;
+ }
+ }
+
+ //Send the password
+ ITDebugLog(@"Sending password.");
+ while (![clientProxy sendPassword:[[NSUserDefaults standardUserDefaults] dataForKey:@"connectPassword"]]) {
+ ITDebugLog(@"Invalid password!");
+ if (![[PreferencesController sharedPrefs] showInvalidPasswordPanel]) {
+ ITDebugLog(@"Giving up connection attempt.");
+ [self disconnect];
+ return -1;
+ }
+ }
+ }
+