Removed the evil "Requires Checkbox" button as per Joe's request.
[MenuTunes.git] / NetworkObject.m
index da316e1..2d7207d 100755 (executable)
 
 @implementation NetworkObject
 
 
 @implementation NetworkObject
 
+- (id)init
+{
+    if ( (self = [super init]) ) {
+        _valid = YES;
+        if (![self requiresPassword]) {
+            _authenticated = YES;
+        } else {
+            _authenticated = NO;
+        }
+    }
+    return self;
+}
+
 - (ITMTRemote *)remote
 {
 - (ITMTRemote *)remote
 {
-    return [[MainController sharedController] currentRemote];
+    if (_authenticated && _valid) {
+        return [[MainController sharedController] currentRemote];
+    } else {
+        return nil;
+    }
 }
 
 - (NSString *)serverName
 }
 
 - (NSString *)serverName
 
 - (BOOL)requiresPassword
 {
 
 - (BOOL)requiresPassword
 {
-    return [[NSUserDefaults standardUserDefaults] boolForKey:@"enableSharingPassword"];
+    return [[[NSUserDefaults standardUserDefaults] dataForKey:@"sharedPlayerPassword"] length];
 }
 
 - (BOOL)sendPassword:(NSData *)password
 {
     if ([password isEqualToData:[[NSUserDefaults standardUserDefaults] dataForKey:@"sharedPlayerPassword"]]) {
 }
 
 - (BOOL)sendPassword:(NSData *)password
 {
     if ([password isEqualToData:[[NSUserDefaults standardUserDefaults] dataForKey:@"sharedPlayerPassword"]]) {
+        _authenticated = YES;
         return YES;
     } else {
         return YES;
     } else {
+        _authenticated = NO;
         return NO;
     }
 }
 
         return NO;
     }
 }
 
+- (void)invalidate
+{
+    _valid = NO;
+}
+
+- (void)makeValid
+{
+    _valid = YES;
+}
+
+- (BOOL)isValid
+{
+    return _valid;
+}
+
 @end
 @end