From: Benjamin R. <be...@us...> - 2004-04-09 04:14:14
|
Update of /cvsroot/ljkit/LJKit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21933 Modified Files: LJServer.h LJServer.m LJAccount.h LJAccount.m Log Message: Added logout method to LJAccount. Also changed the macros in LJServer to define and check ENABLE_REACHABILITY_MONITORING instead of directly querying the OS version for each block of code. Index: LJAccount.h =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJAccount.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LJAccount.h 16 Mar 2004 02:56:49 -0000 1.3 --- LJAccount.h 9 Apr 2004 04:00:58 -0000 1.4 *************** *** 124,127 **** --- 124,135 ---- /*! + @const LJAccountDidLogoutNotification + @discussion + Posted after an account object logs out. + The notification object is the account instance. + */ + FOUNDATION_EXPORT NSString * const LJAccountDidNotLoginNotification; + + /*! @class LJAccount *************** *** 361,364 **** --- 369,382 ---- /*! + @method logout + @abstract Logs out of the LiveJournal server. + @discussion + Since the LiveJournal Client Server Protocol is stateless, logging out does + not result in any communication with the server. This method destroys any + stored password information and posts LJAccountDidLogoutNotification. + */ + - (void)logout; + + /*! @method loginMessage @abstract Obtain the server's login message. Index: LJServer.h =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJServer.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** LJServer.h 27 Mar 2004 20:52:19 -0000 1.5 --- LJServer.h 9 Apr 2004 04:00:58 -0000 1.6 *************** *** 30,36 **** #import <SystemConfiguration/SystemConfiguration.h> @class LJAccount; ! #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 /*! @const LJServerReachabilityDidChangeNotification --- 30,40 ---- #import <SystemConfiguration/SystemConfiguration.h> + #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 + #define ENABLE_REACHABILITY_MONITORING + #endif + @class LJAccount; ! #ifdef ENABLE_REACHABILITY_MONITORING /*! @const LJServerReachabilityDidChangeNotification *************** *** 67,71 **** BOOL _isUsingFastServers; NSData *_loginData; ! #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 SCNetworkReachabilityContext _reachContext; SCNetworkReachabilityRef _target; --- 71,75 ---- BOOL _isUsingFastServers; NSData *_loginData; ! #ifdef ENABLE_REACHABILITY_MONITORING SCNetworkReachabilityContext _reachContext; SCNetworkReachabilityRef _target; *************** *** 104,108 **** - (BOOL)isUsingFastServers; ! #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 /*! @method enableReachabilityMonitoring --- 108,112 ---- - (BOOL)isUsingFastServers; ! #ifdef ENABLE_REACHABILITY_MONITORING /*! @method enableReachabilityMonitoring *************** *** 118,122 **** #endif ! #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 /*! @method disableReachabilityMonitoring --- 122,126 ---- #endif ! #ifdef ENABLE_REACHABILITY_MONITORING /*! @method disableReachabilityMonitoring Index: LJServer.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJServer.m,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** LJServer.m 27 Mar 2004 20:52:19 -0000 1.7 --- LJServer.m 9 Apr 2004 04:00:58 -0000 1.8 *************** *** 32,36 **** #import "URLEncoding.h" ! #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 NSString * const LJServerReachabilityDidChangeNotification = @"LJServerReachabilityDidChange"; #endif --- 32,36 ---- #import "URLEncoding.h" ! #ifdef ENABLE_REACHABILITY_MONITORING NSString * const LJServerReachabilityDidChangeNotification = @"LJServerReachabilityDidChange"; #endif *************** *** 47,51 **** void LJServerStoreCallback(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info); ! #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 void LJServerReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkConnectionFlags flags, void *info); #endif --- 47,51 ---- void LJServerStoreCallback(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info); ! #ifdef ENABLE_REACHABILITY_MONITORING void LJServerReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkConnectionFlags flags, void *info); #endif *************** *** 86,90 **** [_loginData release]; if (_requestTemplate) CFRelease(_requestTemplate); ! #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 [self disableReachabilityMonitoring]; #endif --- 86,90 ---- [_loginData release]; if (_requestTemplate) CFRelease(_requestTemplate); ! #ifdef ENABLE_REACHABILITY_MONITORING [self disableReachabilityMonitoring]; #endif *************** *** 116,120 **** if (_requestTemplate) CFRelease(_requestTemplate); _requestTemplate = NULL; ! #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 // If we were monitoring reachability, the target needs to be updated. if (_target != NULL) { --- 116,120 ---- if (_requestTemplate) CFRelease(_requestTemplate); _requestTemplate = NULL; ! #ifdef ENABLE_REACHABILITY_MONITORING // If we were monitoring reachability, the target needs to be updated. if (_target != NULL) { *************** *** 148,153 **** { [_loginData release]; ! _loginData = LJCreateURLEncodedFormData(loginDict); ! [_loginData retain]; } --- 148,157 ---- { [_loginData release]; ! if (loginDict != nil) { ! _loginData = LJCreateURLEncodedFormData(loginDict); ! [_loginData retain]; ! } else { ! _loginData = nil; ! } } *************** *** 185,189 **** } ! #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 - (void)enableReachabilityMonitoring { --- 189,193 ---- } ! #ifdef ENABLE_REACHABILITY_MONITORING - (void)enableReachabilityMonitoring { *************** *** 197,201 **** #endif ! #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 - (void)disableReachabilityMonitoring { --- 201,205 ---- #endif ! #ifdef ENABLE_REACHABILITY_MONITORING - (void)disableReachabilityMonitoring { *************** *** 305,309 **** } ! #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 void LJServerReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkConnectionFlags flags, void *info) { --- 309,313 ---- } ! #ifdef ENABLE_REACHABILITY_MONITORING void LJServerReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkConnectionFlags flags, void *info) { Index: LJAccount.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJAccount.m,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** LJAccount.m 9 Apr 2004 03:30:09 -0000 1.6 --- LJAccount.m 9 Apr 2004 04:00:58 -0000 1.7 *************** *** 45,48 **** --- 45,49 ---- NSString * const LJAccountDidLoginNotification = @"LJAccountDidLogin"; NSString * const LJAccountDidNotLoginNotification = @"LJAccountDidNotLogin"; + NSString * const LJAccountDidLogoutNotification = @"LJAccountDidLogout"; static NSString *gClientVersion = nil; *************** *** 60,63 **** --- 61,69 ---- @implementation LJAccount + #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3 + - (void)willChangeValueForKey:(id)key { } + - (void)didChangeValueForKey:(id)key { } + #endif + /* This method sets the client name and version to be sent to the server. *************** *** 470,473 **** --- 476,480 ---- [noticeCenter postNotificationName:LJAccountWillLoginNotification object:self userInfo:nil]; + [self willChangeValueForKey:@"isLoggedIn"]; // Configure server object with login information. _isLoggedIn = NO; *************** *** 524,527 **** --- 531,535 ---- [self updateGroupSetWithReply:reply]; _isLoggedIn = YES; + [self didChangeValueForKey:@"isLoggedIn"]; [noticeCenter postNotificationName:LJAccountDidLoginNotification object:self userInfo:nil]; *************** *** 533,536 **** --- 541,556 ---- } + - (void)logout + { + NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; + + [self willChangeValueForKey:@"isLoggedIn"]; + _isLoggedIn = NO; + [[self server] setLoginInfo:nil]; + [self didChangeValueForKey:@"isLoggedIn"]; + [center postNotificationName:LJAccountDidLogoutNotification + object:self userInfo:nil]; + } + - (NSString *)loginMessage { |