X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/6e637324a7d146b5675fec00c819259d7ac9c244..a876619d0c610eaee6aa5e1a105106f265b2c084:/NetworkObject.m?ds=inline diff --git a/NetworkObject.m b/NetworkObject.m index da316e1..8721e98 100755 --- a/NetworkObject.m +++ b/NetworkObject.m @@ -21,9 +21,26 @@ @implementation NetworkObject +- (id)init +{ + if ( (self = [super init]) ) { + _valid = YES; + if (![self requiresPassword]) { + _authenticated = YES; + } else { + _authenticated = NO; + } + } + return self; +} + - (ITMTRemote *)remote { - return [[MainController sharedController] currentRemote]; + if (_authenticated && _valid) { + return [[MainController sharedController] currentRemote]; + } else { + return nil; + } } - (NSString *)serverName @@ -36,16 +53,33 @@ - (BOOL)requiresPassword { - return [[NSUserDefaults standardUserDefaults] boolForKey:@"enableSharingPassword"]; + return ([[[NSUserDefaults standardUserDefaults] dataForKey:@"sharedPlayerPassword"] length] > 0); } - (BOOL)sendPassword:(NSData *)password { if ([password isEqualToData:[[NSUserDefaults standardUserDefaults] dataForKey:@"sharedPlayerPassword"]]) { + _authenticated = YES; return YES; } else { + _authenticated = NO; return NO; } } +- (void)invalidate +{ + _valid = NO; +} + +- (void)makeValid +{ + _valid = YES; +} + +- (BOOL)isValid +{ + return _valid; +} + @end