X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/107e67ed9e5791f210cfaf2185e75ea5b5e84792..a2891d12899c1160b9fcd9b9b195d7d8ee354cb7:/NetworkObject.m?ds=sidebyside diff --git a/NetworkObject.m b/NetworkObject.m index 5ab7c79..7c5a018 100755 --- a/NetworkObject.m +++ b/NetworkObject.m @@ -1,20 +1,29 @@ -// -// NetworkObject.m -// MenuTunes -// -// Created by Kent Sutherland on Tue Oct 28 2003. -// Copyright (c) 2003 __MyCompanyName__. All rights reserved. -// - #import "NetworkObject.h" #import "MainController.h" #import @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 @@ -25,4 +34,35 @@ return name; } +- (BOOL)requiresPassword +{ + 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