More work done to networking. Bugfixes out the wazoo, but there's still
authorKent Sutherland <ksuther@ithinksw.com>
Wed, 29 Oct 2003 06:45:00 +0000 (06:45 +0000)
committerKent Sutherland <ksuther@ithinksw.com>
Wed, 29 Oct 2003 06:45:00 +0000 (06:45 +0000)
like 99 left.

English.lproj/Preferences.nib/classes.nib
English.lproj/Preferences.nib/info.nib
English.lproj/Preferences.nib/keyedobjects.nib
MainController.m
NetworkController.h
NetworkController.m
PreferencesController.h
PreferencesController.m
libValidate.a

index 68f916a..cebb794 100755 (executable)
@@ -20,6 +20,7 @@
                 appearanceEffectPopup = NSPopUpButton; 
                 appearanceSpeedSlider = NSSlider; 
                 artistCheckbox = NSButton; 
+                clientPasswordTextField = NSTextField; 
                 hostTextField = NSTextField; 
                 hotKeysTableView = NSTableView; 
                 launchAtLoginCheckbox = NSButton; 
index d4a5e32..1c8a9f3 100755 (executable)
@@ -9,7 +9,7 @@
                <key>634</key>
                <string>386 421 380 180 0 0 1152 746 </string>
                <key>639</key>
-               <string>412 313 380 122 0 0 1152 746 </string>
+               <string>386 450 380 122 0 0 1152 746 </string>
        </dict>
        <key>IBFramework Version</key>
        <string>349.0</string>
@@ -20,6 +20,8 @@
        <key>IBOpenObjects</key>
        <array>
                <integer>6</integer>
+               <integer>699</integer>
+               <integer>624</integer>
        </array>
        <key>IBSystem Version</key>
        <string>7B85</string>
index 7e4be37..e180aca 100755 (executable)
Binary files a/English.lproj/Preferences.nib/keyedobjects.nib and b/English.lproj/Preferences.nib/keyedobjects.nib differ
index aaddc7f..a9e67e9 100755 (executable)
@@ -945,18 +945,25 @@ static MainController *sharedController;
 
 - (BOOL)connectToServer
 {
+    int result;
     ITDebugLog(@"Attempting to connect to shared remote.");
+    result = [networkController connectToHost:[df stringForKey:@"sharedPlayerHost"]];
     //Connect
-    if ([networkController connectToHost:[df stringForKey:@"sharedPlayerHost"]]) {
+    if (result == 1) {
         currentRemote = [[[networkController networkObject] remote] retain];
         [self timerUpdate];
         //[refreshTimer invalidate];
         ITDebugLog(@"Connection successful.");
         return YES;
-    } else {
+    } else if (result == 0) {
         ITDebugLog(@"Connection failed.");
         currentRemote = [remoteArray objectAtIndex:0];
         return NO;
+    } else if (result == -1) {
+        ITDebugLog(@"Connection failed.");
+        currentRemote = [remoteArray objectAtIndex:0];
+        return NO;
+        //Do something about the password being invalid
     }
 }
 
@@ -977,7 +984,9 @@ static MainController *sharedController;
     if ([networkController checkForServerAtHost:[df stringForKey:@"sharedPlayerHost"]]) {
         ITDebugLog(@"Remote server found.");
         [timer invalidate];
-        [[StatusWindowController sharedController] showReconnectQueryWindow];
+        if (![networkController isConnectedToServer]) {
+            [[StatusWindowController sharedController] showReconnectQueryWindow];
+        }
     } else {
         ITDebugLog(@"Remote server not found.");
     }
@@ -986,9 +995,10 @@ static MainController *sharedController;
 - (void)networkError:(NSException *)exception
 {
     ITDebugLog(@"Remote exception thrown: %@: %@", [exception name], [exception reason]);
-    if ([[exception name] isEqualToString:NSPortTimeoutException]) {
+    NSLog(@"%@", [exception reason]);
+    if ([[exception name] isEqualToString:NSPortTimeoutException] && [networkController isConnectedToServer]) {
         NSRunCriticalAlertPanel(@"Remote MenuTunes Disconnected", @"The MenuTunes server you were connected to stopped responding or quit. MenuTunes will revert back to the local player.", @"OK", nil, nil);
-        if ([networkController isConnectedToServer] && [self disconnectFromServer]) {
+        if ([self disconnectFromServer]) {
             [NSTimer scheduledTimerWithTimeInterval:45 target:self selector:@selector(checkForRemoteServer:) userInfo:nil repeats:YES];
         } else {
             ITDebugLog(@"CRITICAL ERROR, DISCONNECTING!");
index ae40030..662e519 100755 (executable)
@@ -36,7 +36,7 @@
 - (void)stopRemoteServerSearch;
 
 - (void)setServerStatus:(BOOL)status;
-- (BOOL)connectToHost:(NSString *)host;
+- (int)connectToHost:(NSString *)host;
 - (BOOL)checkForServerAtHost:(NSString *)host;
 - (BOOL)disconnect;
 - (BOOL)isServerOn;
index 230e136..65962ba 100755 (executable)
@@ -112,7 +112,7 @@ static NetworkController *sharedController;
     }
 }
 
-- (BOOL)connectToHost:(NSString *)host
+- (int)connectToHost:(NSString *)host
 {
     NSData *fullPass = [[NSUserDefaults standardUserDefaults] dataForKey:@"connectPassword"];
     unsigned char buffer;
@@ -150,18 +150,14 @@ static NetworkController *sharedController;
         if (![clientProxy sendPassword:[[NSUserDefaults standardUserDefaults] dataForKey:@"connectPassword"]]) {
             ITDebugLog(@"Invalid password!");
             [self disconnect];
-            if ( NSRunCriticalAlertPanel(@"Invalid Password", @"The MenuTunes server you attempted to connect to rejected your password. Would you like to try to reconnect?.", @"Yes", @"No", nil) == NSOKButton ) {
-                return [self connectToHost:host];
-            } else {
-                return NO;
-            }
+            return -1;
         }
     }
     
     ITDebugLog(@"Connected to host: %@", host);
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(disconnect) name:NSConnectionDidDieNotification object:clientConnection];
-    connectedToServer = YES;
-    return YES;
+    connectedToServer = 1;
+    return 1;
 }
 
 - (BOOL)disconnect
index 394934a..9ac7365 100755 (executable)
@@ -23,6 +23,7 @@
     IBOutlet NSPopUpButton *appearanceEffectPopup;
     IBOutlet NSSlider *appearanceSpeedSlider;
     IBOutlet NSButton *artistCheckbox;
+    IBOutlet NSTextField *clientPasswordTextField;
     IBOutlet NSTextField *hostTextField;
     IBOutlet NSTableView *hotKeysTableView;
     IBOutlet NSButton *launchAtLoginCheckbox;
index 96c19e8..f6c6d7b 100755 (executable)
@@ -220,9 +220,14 @@ static PreferencesController *prefs = nil;
         [selectSharedPlayerButton setEnabled:state];
         
         if (state) {
+            [selectedPlayerTextField setStringValue:[[[NetworkController sharedController] networkObject] serverName]];
+            [locationTextField setStringValue:[[NetworkController sharedController] remoteHost]];
             [controller connectToServer];
         } else {
+            [selectedPlayerTextField setStringValue:@"No shared player selected."];
+            [locationTextField setStringValue:@"-"];
             [controller disconnectFromServer];
+            
         }
     } else if ( [sender tag] == 5050 ) {
         //Do nothing on table view click
@@ -266,11 +271,13 @@ static PreferencesController *prefs = nil;
         [NSApp endSheet:selectPlayerSheet];
         [selectPlayerSheet orderOut:nil];
         
+        [self changeSharingSetting:clientPasswordTextField];
+        
         if ([selectPlayerBox contentView] == manualView) {
             [df setObject:[hostTextField stringValue] forKey:@"sharedPlayerHost"];
         } else {
             if ([sharingTableView selectedRow] > -1) {
-                [df setObject:[NSString stringWithCString:inet_ntoa((*(struct sockaddr_in*)[[[[NetworkController sharedController] remoteServices] objectAtIndex:[sharingTableView selectedRow]] bytes]).sin_addr)] forKey:@"sharedPlayerHost"];
+                [df setObject:[NSString stringWithCString:inet_ntoa((*(struct sockaddr_in*)[[[[[[NetworkController sharedController] remoteServices] objectAtIndex:[sharingTableView selectedRow]] addresses] objectAtIndex:0] bytes]).sin_addr)] forKey:@"sharedPlayerHost"];
             }
         }
         
index 4a42a33..61c6a97 100755 (executable)
Binary files a/libValidate.a and b/libValidate.a differ