Fixed a crash when unchecking share this player. Also trying to make the
authorKent Sutherland <ksuther@ithinksw.com>
Thu, 4 Dec 2003 23:23:10 +0000 (23:23 +0000)
committerKent Sutherland <ksuther@ithinksw.com>
Thu, 4 Dec 2003 23:23:10 +0000 (23:23 +0000)
server disconnect people who are connected already.

MainController.m
NetworkController.m
NetworkObject.h
NetworkObject.m
libValidate.a

index 67ce65d..fbeae9d 100755 (executable)
@@ -290,6 +290,9 @@ static MainController *sharedController;
 {
     if ([networkController isConnectedToServer]) {
         [statusItem setMenu:[menuController menu]];
+        if ([[networkController networkObject] remote] == nil) {
+            [self networkError:nil];
+        }
     }
     
     if ( [self songChanged] && (timerUpdating != YES) ) {
@@ -997,7 +1000,7 @@ static MainController *sharedController;
     if ([networkController checkForServerAtHost:[df stringForKey:@"sharedPlayerHost"]]) {
         ITDebugLog(@"Remote server found.");
         [timer invalidate];
-        if (![networkController isConnectedToServer]) {
+        if (![networkController isServerOn] && ![networkController isConnectedToServer]) {
             [[StatusWindowController sharedController] showReconnectQueryWindow];
         }
     } else {
index 49b8321..1d180c6 100755 (executable)
@@ -112,7 +112,6 @@ static NetworkController *sharedController;
         [service stop];
         [serverConnection registerName:nil];
         [serverConnection release];
-        [clientProxy release];
         ITDebugLog(@"Stopped server.");
         serverOn = NO;
     }
@@ -200,6 +199,7 @@ static NetworkController *sharedController;
     NSConnection *testConnection;
     NSSocketPort *testPort;
     NetworkObject *tempProxy;
+    BOOL valid;
     ITDebugLog(@"Checking for shared remote at %@.", host);
     if (fullPass) {
         [fullPass getBytes:&buffer range:NSMakeRange(6, 4)];
@@ -216,6 +216,7 @@ static NetworkController *sharedController;
         [testConnection setReplyTimeout:2];
         tempProxy = (NetworkObject *)[testConnection rootProxy];
         [tempProxy serverName];
+        valid = [tempProxy isValid];
     NS_HANDLER
         ITDebugLog(@"Connection to host failed: %@", host);
         [testConnection release];
@@ -231,7 +232,7 @@ static NetworkController *sharedController;
     }
     [testConnection release];
     [testPort release];
-    return YES;
+    return valid;
 }
 
 - (BOOL)isServerOn
index 2222414..0e185d4 100755 (executable)
 
 @interface NetworkObject : NSObject
 {
-    BOOL _authenticated;
+    BOOL _authenticated, _valid;
 }
 - (ITMTRemote *)remote;
 - (NSString *)serverName;
 
 - (BOOL)requiresPassword;
 - (BOOL)sendPassword:(NSData *)password;
+
+- (void)invalidate;
+- (BOOL)isValid;
 @end
index 4473970..a29c3f5 100755 (executable)
@@ -24,6 +24,7 @@
 - (id)init
 {
     if ( (self = [super init]) ) {
+        _valid = YES;
         if (![self requiresPassword]) {
             _authenticated = YES;
         } else {
@@ -35,7 +36,7 @@
 
 - (ITMTRemote *)remote
 {
-    if (_authenticated) {
+    if (_authenticated && _valid) {
         return [[MainController sharedController] currentRemote];
     } else {
         return nil;
     }
 }
 
+- (void)invalidate
+{
+    _valid = NO;
+}
+
+- (BOOL)isValid
+{
+    return _valid;
+}
+
 @end
index f825a30..71a8a25 100755 (executable)
Binary files a/libValidate.a and b/libValidate.a differ