You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
(5) |
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(5) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
From: Fraser S. <fra...@us...> - 2005-11-18 20:18:44
|
Update of /cvsroot/ljkit/LJKit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14183 Modified Files: LJEntry_Metadata.h LJEntry_Metadata.m Log Message: Initial support for tags in LJEntry metadata Index: LJEntry_Metadata.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJEntry_Metadata.m,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LJEntry_Metadata.m 28 Jul 2004 05:38:20 -0000 1.2 --- LJEntry_Metadata.m 18 Nov 2005 20:18:36 -0000 1.3 *************** *** 166,168 **** --- 166,177 ---- } + - (NSString *)tags + { + return [self stringForProperty: @"taglist"]; + } + + - (void)setTags:(NSString *)newTags + { + [self setString: newTags forProperty: @"taglist"]; + } @end Index: LJEntry_Metadata.h =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJEntry_Metadata.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LJEntry_Metadata.h 28 Jul 2004 05:38:20 -0000 1.2 --- LJEntry_Metadata.h 18 Nov 2005 20:18:36 -0000 1.3 *************** *** 208,210 **** --- 208,221 ---- - (NSURL *)syndicatedItemURL; + /*! + @method setTags: + @abstract Set the tag string of the receiver. + */ + - (NSString *)tags; + + /*! + @method setTags: + @abstract Set the tag string of the receiver. + */ + - (void)setTags:(NSString *)newTags; @end |
From: Fraser S. <fra...@us...> - 2004-10-10 21:42:50
|
Update of /cvsroot/ljkit/LJKit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26675 Modified Files: LJAccount.m Log Message: Converted LJAccount to post all its notifications using -[NSObject performSelectorOnMainThread] which makes calling login asynchronously much more reliable Index: LJAccount.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJAccount.m,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** LJAccount.m 10 Oct 2004 16:35:51 -0000 1.10 --- LJAccount.m 10 Oct 2004 21:42:12 -0000 1.11 *************** *** 421,426 **** if (parameters) [info setObject:parameters forKey:@"LJParameters"]; [info setObject:[NSNumber numberWithInt:(connectionID++)] forKey:@"LJConnection"]; ! [noticeCenter postNotificationName:LJAccountWillConnectNotification ! object:self userInfo:info]; // Do the dirty deed. NS_DURING --- 421,432 ---- if (parameters) [info setObject:parameters forKey:@"LJParameters"]; [info setObject:[NSNumber numberWithInt:(connectionID++)] forKey:@"LJConnection"]; ! ! // [FS] Fire notification with -performSelectorOnMainThread: ! NSNotification *willLoginNote = [NSNotification notificationWithName: LJAccountWillConnectNotification object: self userInfo: info]; ! [noticeCenter performSelectorOnMainThread: @selector(postNotification:) ! withObject: willLoginNote ! waitUntilDone: YES]; ! // End change. ! // Do the dirty deed. NS_DURING *************** *** 449,454 **** if (reply) [info setObject:reply forKey:@"LJReply"]; if (exception) [info setObject:exception forKey:@"LJException"]; ! [noticeCenter postNotificationName:LJAccountDidConnectNotification ! object:self userInfo:info]; [info release]; [exception raise]; // will do nothing if no exception was set --- 455,468 ---- if (reply) [info setObject:reply forKey:@"LJReply"]; if (exception) [info setObject:exception forKey:@"LJException"]; ! ! // [FS] Change to fire notification onMainThread. ! NSNotification *didLoginNote = [NSNotification notificationWithName: LJAccountDidConnectNotification ! object: self ! userInfo: info]; ! [noticeCenter performSelectorOnMainThread: @selector(postNotification:) ! withObject: didLoginNote ! waitUntilDone: YES]; ! // end ! [info release]; [exception raise]; // will do nothing if no exception was set *************** *** 490,495 **** NSAssert(password != nil, @"Password must not be nil."); NSAssert((loginFlags & LJReservedLoginFlags) == 0, @"A reserved login flag was set."); ! [noticeCenter postNotificationName:LJAccountWillLoginNotification ! object:self userInfo:nil]; [self willChangeValueForKey:@"isLoggedIn"]; // Configure server object with login information. --- 504,518 ---- NSAssert(password != nil, @"Password must not be nil."); NSAssert((loginFlags & LJReservedLoginFlags) == 0, @"A reserved login flag was set."); ! ! // [FS] Convert to fire notification onMainThread ! NSNotification *loginNote = [NSNotification notificationWithName: LJAccountWillLoginNotification ! object: self ! userInfo: nil]; ! [noticeCenter performSelectorOnMainThread: @selector(postNotification:) ! withObject: loginNote ! waitUntilDone: YES]; ! ! // [FS] end change. ! [self willChangeValueForKey:@"isLoggedIn"]; // Configure server object with login information. *************** *** 519,524 **** info = [NSDictionary dictionaryWithObject:localException forKey:@"LJException"]; ! [noticeCenter postNotificationName:LJAccountDidNotLoginNotification ! object:self userInfo:info]; [localException raise]; NS_ENDHANDLER --- 542,555 ---- info = [NSDictionary dictionaryWithObject:localException forKey:@"LJException"]; ! ! // [FS] onMainThread conversion ! NSNotification *failureNote = [NSNotification notificationWithName: LJAccountDidNotLoginNotification ! object: self ! userInfo: info]; ! [noticeCenter performSelectorOnMainThread: @selector(postNotification:) ! withObject: failureNote ! waitUntilDone: YES]; ! // [FS] end. ! [localException raise]; NS_ENDHANDLER *************** *** 548,553 **** _isLoggedIn = YES; [self didChangeValueForKey:@"isLoggedIn"]; ! [noticeCenter postNotificationName:LJAccountDidLoginNotification ! object:self userInfo:nil]; } --- 579,591 ---- _isLoggedIn = YES; [self didChangeValueForKey:@"isLoggedIn"]; ! ! // [FS] onMainThread conversion ! NSNotification *successNote = [NSNotification notificationWithName: LJAccountDidLoginNotification ! object: self ! userInfo: nil]; ! [noticeCenter performSelectorOnMainThread: @selector(postNotification:) ! withObject: successNote ! waitUntilDone: YES]; ! // [FS] end change. } |
From: Fraser S. <fra...@us...> - 2004-10-10 16:36:24
|
Update of /cvsroot/ljkit/LJKit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24647 Modified Files: LJAccount.h LJAccount.m LJAccount_EditFriends.h LJAccount_EditFriends.m Log Message: Improvements to better support Key-Value Observing. Added -relationshipArray method to return all friends incoming, outgoing and mutual. Added LJAccount{Will,Did}DownloadFriendsNotification to better support aynchronous logging in. Added -defaultUserPictureKeyword: method, which helps with object selection in a Cocoa-bound popup list. I've tried to surround changes with "[FS]" for easy searching. Index: LJAccount_EditFriends.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJAccount_EditFriends.m,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** LJAccount_EditFriends.m 6 Oct 2004 08:21:31 -0000 1.4 --- LJAccount_EditFriends.m 10 Oct 2004 16:35:51 -0000 1.5 *************** *** 52,55 **** --- 52,60 ---- - (void)downloadFriends { + // [FS] + NSNotification *note = [NSNotification notificationWithName: LJAccountWillDownloadFriendsNotification object: self]; + [[NSNotificationCenter defaultCenter] performSelectorOnMainThread: @selector(postNotification:) + withObject: note + waitUntilDone: YES]; NSDictionary *parameters, *reply; *************** *** 68,71 **** --- 73,81 ---- _friendsSyncDate = [[NSDate alloc] init]; [self updateGroupSetWithReply:reply]; + + note = [NSNotification notificationWithName: LJAccountDidDownloadFriendsNotification object: self]; + [[NSNotificationCenter defaultCenter] performSelectorOnMainThread: @selector(postNotification:) + withObject: note + waitUntilDone: NO]; } *************** *** 202,205 **** --- 212,223 ---- } + - (NSArray *)relationshipArray { + NSMutableSet *set = [[NSMutableSet alloc] init]; + [set addObjectsFromArray: [self friendArray]]; + [set addObjectsFromArray: [self friendOfArray]]; + + return [[set allObjects] sortedArrayUsingSelector: @selector(compare:)]; + } + - (NSEnumerator *)friendOfEnumerator { *************** *** 303,308 **** [buddy _setOutgoingFriendship:YES]; [_friendSet addObject:buddy]; - [buddy release]; if(_orderedFriendArrayCache) { // The underlying set changed, so change the cache --- 321,327 ---- [buddy _setOutgoingFriendship:YES]; [_friendSet addObject:buddy]; + [buddy release]; + if(_orderedFriendArrayCache) { // The underlying set changed, so change the cache Index: LJAccount.h =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJAccount.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** LJAccount.h 6 Oct 2004 08:21:31 -0000 1.7 --- LJAccount.h 10 Oct 2004 16:35:51 -0000 1.8 *************** *** 133,136 **** --- 133,152 ---- /*! + @const LJAccountWillDownloadFriendsNotification + @discussion + Posted before an account object downloads friend/group info. + The notification object is the account instance. + */ + FOUNDATION_EXPORT NSString * const LJAccountWillDownloadFriendsNotification; + + /*! + @const LJAccountDidDownloadFriendsNotification + @discussion + Posted after an account object downloads friend/group info. + The notification object is the account instance. + */ + FOUNDATION_EXPORT NSString * const LJAccountDidDownloadFriendsNotification; + + /*! @class LJAccount *************** *** 453,456 **** --- 469,480 ---- /*! + @method defaultUserPictureURL + @abstract Returns the URL of the default user picture. + @discussion + This property is preserved during archiving. + */ + - (NSString *)defaultUserPictureKeyword; + + /*! @method userPicturesMenu @abstract Returns an NSMenu of all picture keywords for the receiver. Index: LJAccount_EditFriends.h =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJAccount_EditFriends.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** LJAccount_EditFriends.h 14 May 2003 05:39:39 -0000 1.1.1.1 --- LJAccount_EditFriends.h 10 Oct 2004 16:35:51 -0000 1.2 *************** *** 143,146 **** --- 143,155 ---- /*! + @method relationshipArray + @abstract Returns all the friends with which the receiver has a relationship + @discussion + In contrast to -friendArray and -friendOfArray, this method returns + a sorted array in which are mixed mutual, incoming and outgoing relationships. + */ + - (NSArray *)relationshipArray; + + /*! @method watchedCommunityArray @abstract Returns the communities the receiver is watching. Index: LJAccount.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJAccount.m,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** LJAccount.m 6 Oct 2004 08:21:31 -0000 1.9 --- LJAccount.m 10 Oct 2004 16:35:51 -0000 1.10 *************** *** 48,51 **** --- 48,55 ---- NSString * const LJAccountDidLogoutNotification = @"LJAccountDidLogout"; + // [FS] These are handy if we're doing asynchronous login and download + NSString * const LJAccountWillDownloadFriendsNotification = @"LJAccountWillDownloadFriends"; + NSString * const LJAccountDidDownloadFriendsNotification = @"LJAccountDidDownloadFriends"; + static NSString *gClientVersion = nil; *************** *** 603,606 **** --- 607,622 ---- } + - (NSString *)defaultUserPictureKeyword { + // This may potentially be expensive + NSEnumerator *en = [[_userPicturesDictionary allKeys] objectEnumerator]; + NSURL *defaultURL = [self defaultUserPictureURL]; + NSString *key; + while(key = [en nextObject]) { + if([[_userPicturesDictionary objectForKey: key] isEqualTo: defaultURL]) + return key; + } + return nil; + } + - (NSMenu *)userPicturesMenu { *************** *** 761,763 **** --- 777,793 ---- } + // [FS] KVO - there may be simplifcations to be made here. + + (BOOL)automaticallyNotifiesObserversForKey:(NSString *)theKey { + BOOL automatic; + if ([theKey isEqualToString:@"friendArray"]) { + automatic=NO; + } + else if ([theKey isEqualToString:@"groupArray"]) { + automatic=NO; + } + else { + automatic=[super automaticallyNotifiesObserversForKey:theKey]; + } + return automatic; + } @end |
From: Fraser S. <fra...@us...> - 2004-10-06 08:21:43
|
Update of /cvsroot/ljkit/LJKit/LJKit.pbproj In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19475/LJKit.pbproj Modified Files: project.pbxproj Log Message: Updates for better KVO compliance Index: project.pbxproj =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJKit.pbproj/project.pbxproj,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** project.pbxproj 10 Jan 2004 08:50:08 -0000 1.3 --- project.pbxproj 6 Oct 2004 08:21:31 -0000 1.4 *************** *** 7,12 **** objects = { 014CEA440018CDF011CA2923 = { - buildRules = ( - ); buildSettings = { COPY_PHASE_STRIP = NO; --- 7,10 ---- *************** *** 23,28 **** }; 014CEA450018CDF011CA2923 = { - buildRules = ( - ); buildSettings = { COPY_PHASE_STRIP = YES; --- 21,24 ---- *************** *** 110,115 **** }; 0867D69BFE84028FC02AAC07 = { ! fallbackIsa = PBXFileReference; ! isa = PBXFrameworkReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; --- 106,110 ---- }; 0867D69BFE84028FC02AAC07 = { ! isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; *************** *** 119,124 **** }; 0867D6A5FE840307C02AAC07 = { ! fallbackIsa = PBXFileReference; ! isa = PBXFrameworkReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; --- 114,118 ---- }; 0867D6A5FE840307C02AAC07 = { ! isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; *************** *** 169,174 **** //104 1058C7B1FEA5585E11CA2CBB = { ! fallbackIsa = PBXFileReference; ! isa = PBXFrameworkReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; --- 163,167 ---- //104 1058C7B1FEA5585E11CA2CBB = { ! isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; *************** *** 216,219 **** --- 209,253 ---- //433 //434 + //5F0 + //5F1 + //5F2 + //5F3 + //5F4 + 5F548C4A07133B7600515272 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = LJUserEntity.h; + refType = 4; + sourceTree = "<group>"; + }; + 5F548C4B07133B7600515272 = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + path = LJUserEntity.m; + refType = 4; + sourceTree = "<group>"; + }; + 5F548C4C07133B7600515272 = { + fileRef = 5F548C4A07133B7600515272; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + Public, + ); + }; + }; + 5F548C4D07133B7600515272 = { + fileRef = 5F548C4B07133B7600515272; + isa = PBXBuildFile; + settings = { + }; + }; + //5F0 + //5F1 + //5F2 + //5F3 + //5F4 //BC0 //BC1 *************** *** 318,321 **** --- 352,356 ---- BCBC6AA905AB976B000EFE4A, BCBC6AAB05AB9849000EFE4A, + 5F548C4C07133B7600515272, ); isa = PBXHeadersBuildPhase; *************** *** 513,516 **** --- 548,552 ---- BC72DB13058B2AFA00784C4A, BC72DB14058B2AFA00784C4A, + 5F548C4D07133B7600515272, ); isa = PBXSourcesBuildPhase; *************** *** 650,655 **** }; BC72DB1B058B2AFA00784C4A = { - explicitFileType = text.plist.xml; isa = PBXFileReference; path = Info.plist; refType = 4; --- 686,691 ---- }; BC72DB1B058B2AFA00784C4A = { isa = PBXFileReference; + lastKnownFileType = text.xml; path = Info.plist; refType = 4; *************** *** 887,890 **** --- 923,928 ---- F52E1F010357A538010C7683, F52E1F020357A538010C7683, + 5F548C4A07133B7600515272, + 5F548C4B07133B7600515272, ); isa = PBXGroup; *************** *** 1125,1130 **** }; F5992D0C03786BB6012C19B1 = { ! fallbackIsa = PBXFileReference; ! isa = PBXFrameworkReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; --- 1163,1167 ---- }; F5992D0C03786BB6012C19B1 = { ! isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; |
From: Fraser S. <fra...@us...> - 2004-10-06 08:21:43
|
Update of /cvsroot/ljkit/LJKit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19475 Modified Files: LJAccount.h LJAccount.m LJAccount_EditFriends.m LJKit.h Log Message: Updates for better KVO compliance Index: LJAccount_EditFriends.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJAccount_EditFriends.m,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LJAccount_EditFriends.m 5 Oct 2004 20:21:49 -0000 1.3 --- LJAccount_EditFriends.m 6 Oct 2004 08:21:31 -0000 1.4 *************** *** 43,48 **** --- 43,50 ---- // Update the static ordered array cache if(_orderedGroupArrayCache) { + [self willChangeValueForKey: @"groupArray"]; [_orderedGroupArrayCache release]; _orderedGroupArrayCache = [[[_groupSet allObjects] sortedArrayUsingSelector: @selector(compare:)] retain]; + [self didChangeValueForKey: @"groupArray"]; } } *************** *** 104,109 **** --- 106,113 ---- if(_orderedFriendArrayCache) { // The underlying set changed, so update the cache + [self willChangeValueForKey: @"friendArray"]; [_orderedFriendArrayCache release]; _orderedFriendArrayCache = [[[_friendSet allObjects] sortedArrayUsingSelector:@selector(compare:)] retain]; + [self didChangeValueForKey: @"friendArray"]; } *************** *** 180,184 **** _orderedGroupArrayCache = [[[_groupSet allObjects] sortedArrayUsingSelector: @selector(compare:)] retain]; ! return [[_orderedGroupArrayCache copy] autorelease]; //[[_groupSet allObjects] sortedArrayUsingSelector:@selector(compare:)]; } --- 184,188 ---- _orderedGroupArrayCache = [[[_groupSet allObjects] sortedArrayUsingSelector: @selector(compare:)] retain]; ! return [[_orderedGroupArrayCache copy] autorelease]; } *************** *** 303,308 **** --- 307,314 ---- if(_orderedFriendArrayCache) { // The underlying set changed, so change the cache + [self willChangeValueForKey: @"friendArray"]; [_orderedFriendArrayCache release]; _orderedFriendArrayCache = [[[_friendSet allObjects] sortedArrayUsingSelector:@selector(compare:)] retain]; + [self didChangeValueForKey: @"friendArray"]; } *************** *** 320,325 **** --- 326,333 ---- if(_orderedFriendArrayCache) { + [self willChangeValueForKey: @"friendArray"]; [_orderedFriendArrayCache release]; _orderedFriendArrayCache = [[[_friendSet allObjects] sortedArrayUsingSelector:@selector(compare:)] retain]; + [self didChangeValueForKey: @"friendArray"]; } } *************** *** 343,348 **** --- 351,358 ---- // Update the static ordered array cache if(_orderedGroupArrayCache) { + [self willChangeValueForKey: @"groupArray"]; [_orderedGroupArrayCache release]; _orderedGroupArrayCache = [[[_groupSet allObjects] sortedArrayUsingSelector: @selector(compare:)] retain]; + [self didChangeValueForKey: @"groupArray"]; } *************** *** 372,377 **** --- 382,389 ---- // Update the static ordered array cache if(_orderedGroupArrayCache) { + [self willChangeValueForKey: @"groupArray"]; [_orderedGroupArrayCache release]; _orderedGroupArrayCache = [[[_groupSet allObjects] sortedArrayUsingSelector: @selector(compare:)] retain]; + [self didChangeValueForKey: @"groupArray"]; } } Index: LJAccount.h =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJAccount.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** LJAccount.h 5 Oct 2004 20:21:49 -0000 1.6 --- LJAccount.h 6 Oct 2004 08:21:31 -0000 1.7 *************** *** 421,424 **** --- 421,436 ---- /*! + @method userPictureKeywords + @abstract Returns an NSArray of account picture keywords in NSStrings. + @discussion + If you provided the LJGetPicturesLoginFlag to the loginWithPassword:flags: + method, this method will return an NSArray of NSStrings. Otherwise, returns nil. + + This property is preserved during archiving. + */ + - (NSArray *)userPictureKeywords; + + + /*! @method userPicturesDictionary @abstract Returns a dictionary of account picture keywords and URLs. Index: LJAccount.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJAccount.m,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** LJAccount.m 28 Jul 2004 05:38:20 -0000 1.8 --- LJAccount.m 6 Oct 2004 08:21:31 -0000 1.9 *************** *** 60,63 **** --- 60,68 ---- @end + @interface LJAccount (PrivateImpl) + - (void)setJournalArray:(NSArray *)aJournalArray; + - (void) setUserPicturesDictionary: (NSDictionary *)aDict; + @end + @implementation LJAccount *************** *** 106,109 **** --- 111,117 ---- gClientVersion = [[NSString alloc] initWithFormat:@"MacOSX-%@/%@", name, version]; NSLog(@"LJKit Client Version: %@", gClientVersion); + + // Set up KVO for the dependent key "userPictureKeywords" which depends on userPicturesDictionary + [self setKeys: [NSArray arrayWithObject: @"userPicturesDictionary"] triggerChangeNotificationsForDependentKey: @"userPictureKeywords"]; } } *************** *** 202,205 **** --- 210,214 ---- } } + return self; } *************** *** 462,467 **** url = (key != nil ? [NSURL URLWithString:key] : nil); SafeSetObject(&_defaultUserPictureURL, url); ! [_userPicturesDictionary release]; ! _userPicturesDictionary = [userPics copy]; [userPics release]; } --- 471,477 ---- url = (key != nil ? [NSURL URLWithString:key] : nil); SafeSetObject(&_defaultUserPictureURL, url); ! ! // [FS] Added use of accessor here ! [self setUserPicturesDictionary: [userPics copy]]; [userPics release]; } *************** *** 520,525 **** } journals = [LJJournal _journalArrayFromLoginReply:reply account:self]; ! [_journalArray release]; ! _journalArray = [journals retain]; if (loginFlags & LJGetMoodsLoginFlag) { [_moods updateMoodsWithLoginReply:reply]; --- 530,535 ---- } journals = [LJJournal _journalArrayFromLoginReply:reply account:self]; ! // [FS] Changed this from direct ivar access for KVO reasons ! [self setJournalArray: journals]; if (loginFlags & LJGetMoodsLoginFlag) { [_moods updateMoodsWithLoginReply:reply]; *************** *** 570,573 **** --- 580,588 ---- } + - (NSArray *)userPictureKeywords { + // [FS] This is potenitally a performance hot spot, but let's be guided by profiling. + return [[_userPicturesDictionary allKeys] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]; + } + - (NSDictionary *)userPicturesDictionary { *************** *** 575,578 **** --- 590,601 ---- } + // [FS] For key value observing + - (void) setUserPicturesDictionary: (NSDictionary *)aDict { + NSLog(@"Setting user pictures dictionary"); + [aDict retain]; + [_userPicturesDictionary release]; + _userPicturesDictionary = aDict; + } + - (NSURL *)defaultUserPictureURL { *************** *** 630,633 **** --- 653,667 ---- } + // =========================================================== + // - setJournalArray: + // =========================================================== + - (void)setJournalArray:(NSArray *)aJournalArray { + if (_journalArray != aJournalArray) { + [aJournalArray retain]; + [_journalArray release]; + _journalArray = aJournalArray; + } + } + - (LJJournal *)defaultJournal { Index: LJKit.h =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJKit.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** LJKit.h 14 May 2003 05:39:47 -0000 1.1.1.1 --- LJKit.h 6 Oct 2004 08:21:31 -0000 1.2 *************** *** 91,92 **** --- 91,93 ---- #import <LJKit/LJGroup.h> #import <LJKit/LJHttpURLs.h> + #import <LJKit/LJUserEntity.h> \ No newline at end of file |
From: Fraser S. <fra...@us...> - 2004-10-05 20:22:06
|
Update of /cvsroot/ljkit/LJKit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1864 Modified Files: LJAccount.h LJAccount_EditFriends.m Log Message: Performance fixes for -friendArray: and -groupArray: - avoid re-sorting the array every time it's called. This kills Xjournal. Index: LJAccount_EditFriends.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJAccount_EditFriends.m,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LJAccount_EditFriends.m 10 Jan 2004 08:35:23 -0000 1.2 --- LJAccount_EditFriends.m 5 Oct 2004 20:21:49 -0000 1.3 *************** *** 40,43 **** --- 40,49 ---- [_groupsSyncDate release]; _groupsSyncDate = [[NSDate alloc] init]; + + // Update the static ordered array cache + if(_orderedGroupArrayCache) { + [_orderedGroupArrayCache release]; + _orderedGroupArrayCache = [[[_groupSet allObjects] sortedArrayUsingSelector: @selector(compare:)] retain]; + } } *************** *** 95,98 **** --- 101,111 ---- [_friendsSyncDate release]; _friendsSyncDate = [[NSDate alloc] init]; + + if(_orderedFriendArrayCache) { + // The underlying set changed, so update the cache + [_orderedFriendArrayCache release]; + _orderedFriendArrayCache = [[[_friendSet allObjects] sortedArrayUsingSelector:@selector(compare:)] retain]; + } + return YES; } *************** *** 144,148 **** - (NSArray *)friendArray { ! return [[_friendSet allObjects] sortedArrayUsingSelector:@selector(compare:)]; } --- 157,166 ---- - (NSArray *)friendArray { ! // Lazily create the cache the first time it's needed ! if(!_orderedFriendArrayCache) ! _orderedFriendArrayCache = [[[_friendSet allObjects] sortedArrayUsingSelector:@selector(compare:)] retain]; ! ! // return the cached array ! return [[_orderedFriendArrayCache copy] autorelease]; } *************** *** 159,163 **** - (NSArray *)groupArray { ! return [[_groupSet allObjects] sortedArrayUsingSelector:@selector(compare:)]; } --- 177,184 ---- - (NSArray *)groupArray { ! if(!_orderedGroupArrayCache) ! _orderedGroupArrayCache = [[[_groupSet allObjects] sortedArrayUsingSelector: @selector(compare:)] retain]; ! ! return [[_orderedGroupArrayCache copy] autorelease]; //[[_groupSet allObjects] sortedArrayUsingSelector:@selector(compare:)]; } *************** *** 279,282 **** --- 300,310 ---- [_friendSet addObject:buddy]; [buddy release]; + + if(_orderedFriendArrayCache) { + // The underlying set changed, so change the cache + [_orderedFriendArrayCache release]; + _orderedFriendArrayCache = [[[_friendSet allObjects] sortedArrayUsingSelector:@selector(compare:)] retain]; + } + return buddy; } *************** *** 290,293 **** --- 318,326 ---- [_friendSet removeObject:buddy]; [buddy _setOutgoingFriendship:NO]; + + if(_orderedFriendArrayCache) { + [_orderedFriendArrayCache release]; + _orderedFriendArrayCache = [[[_friendSet allObjects] sortedArrayUsingSelector:@selector(compare:)] retain]; + } } *************** *** 307,310 **** --- 340,350 ---- [_groupSet addObject:group]; [group release]; + + // Update the static ordered array cache + if(_orderedGroupArrayCache) { + [_orderedGroupArrayCache release]; + _orderedGroupArrayCache = [[[_groupSet allObjects] sortedArrayUsingSelector: @selector(compare:)] retain]; + } + return group; } *************** *** 329,332 **** --- 369,378 ---- [group removeFriend:buddy]; } + + // Update the static ordered array cache + if(_orderedGroupArrayCache) { + [_orderedGroupArrayCache release]; + _orderedGroupArrayCache = [[[_groupSet allObjects] sortedArrayUsingSelector: @selector(compare:)] retain]; + } } Index: LJAccount.h =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJAccount.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** LJAccount.h 28 Jul 2004 05:38:20 -0000 1.5 --- LJAccount.h 5 Oct 2004 20:21:49 -0000 1.6 *************** *** 169,172 **** --- 169,178 ---- NSDate *_groupsSyncDate; NSDate *_friendsSyncDate; + + // For efficiency, keep an ordered cache of friends, + // which we only update when _friendSet changes + NSArray *_orderedFriendArrayCache; + NSArray *_orderedGroupArrayCache; + // for internal linked list LJAccount *_nextAccount; |
From: Benjamin R. <be...@us...> - 2004-07-28 05:38:31
|
Update of /cvsroot/ljkit/LJKit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8929 Modified Files: LJHttpURLs.m LJAccount.m LJEntryRoot.m LJEntry_Metadata.h LJServer.m LJJournal.m LJAccount.h LJFriend.m LJEntry_Metadata.m LJJournal.h LJFriend.h LJHttpURLs.h Added Files: LJUserEntity_Private.h LJUserEntity.h LJUserEntity.m Log Message: New class, LJUserEntity, is a parent class to LJAccount and LJFriend. This allowed some refactoring in LJHttpURLs. LJEntry_Metadata has been updated to include accessors for several new metadata items. Throughout the code direct variable manipulation has been replaced with use of accessors to make the classes more KVC friendly. I made these changes ages ago and only just cleaned things up. It compiles for me, but I may have broken some things. --- NEW FILE: LJUserEntity.h --- /* LJKit: an Objective-C implementation of the LiveJournal client protocol Copyright (C) 2002-2003 Benjamin Peter Ragheb This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA You may contact the author via email at be...@li.... */ #import <Foundation/Foundation.h> @class LJAccount; @interface LJUserEntity : NSObject { NSString *_username, *_fullname; } /*! @method username @abstract Obtain the username of the receiver. */ - (NSString *)username; /*! @method fullname @abstract Obtain the full name of the receiver. @discussion Returns the receiver's full name, as reported by the server. If not available, this method returns the receiver's username. */ - (NSString *)fullname; @end Index: LJHttpURLs.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJHttpURLs.m,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** LJHttpURLs.m 16 Mar 2004 02:54:35 -0000 1.5 --- LJHttpURLs.m 28 Jul 2004 05:38:20 -0000 1.6 *************** *** 20,47 **** */ #import "LJHttpURLs.h" - @implementation LJAccount (LJHttpURLs) - - - (NSURL *)userProfileHttpURL - { - NSString *s; - s = [NSString stringWithFormat:@"/userinfo.bml?user=%@", _username]; - return [[NSURL URLWithString:s relativeToURL:[_server URL]] absoluteURL]; - } - - - (NSURL *)memoriesHttpURL - { - NSString *s = [NSString stringWithFormat:@"/tools/memories.bml?user=%@", _username]; - return [[NSURL URLWithString:s relativeToURL:[_server URL]] absoluteURL]; - } - - - (NSURL *)toDoListHttpURL - { - NSString *s = [NSString stringWithFormat:@"/todo/?user=%@", _username]; - return [[NSURL URLWithString:s relativeToURL:[_server URL]] absoluteURL]; - } - - @end @implementation LJJournal (LJHttpURLs) --- 20,28 ---- */ + #import "LJAccount.h" + #import "LJServer.h" #import "LJHttpURLs.h" + #import "LJUserEntity_Private.h" @implementation LJJournal (LJHttpURLs) *************** *** 69,74 **** { NSString *s; ! // New URL Code: remove "day" from URL ! s = [date descriptionWithCalendarFormat:@"day/%Y/%m/%d/" timeZone:nil locale:nil]; return [[NSURL URLWithString:s relativeToURL:[self recentEntriesHttpURL]] absoluteURL]; } --- 50,54 ---- { NSString *s; ! s = [date descriptionWithCalendarFormat:@"%Y/%m/%d/" timeZone:nil locale:nil]; return [[NSURL URLWithString:s relativeToURL:[self recentEntriesHttpURL]] absoluteURL]; } *************** *** 76,79 **** --- 56,60 ---- @end + @implementation LJEntryRoot (LJHttpURLs) *************** *** 115,118 **** --- 96,100 ---- @end + @implementation LJGroup (LJHttpURLs) *************** *** 125,182 **** @end ! @implementation LJFriend (LJHttpURLs) - (NSURL *)userProfileHttpURL { ! NSString *s = [NSString stringWithFormat:@"/userinfo.bml?user=%@", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] URL]] absoluteURL]; } - (NSURL *)memoriesHttpURL { ! NSString *s = [NSString stringWithFormat:@"/tools/memories.bml?user=%@", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] URL]] absoluteURL]; } - (NSURL *)toDoListHttpURL { ! NSString *s = [NSString stringWithFormat:@"/todo/?user=%@", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] URL]] absoluteURL]; } - (NSURL *)rssFeedURL { ! NSString *s = [NSString stringWithFormat:@"/users/%@/data/rss", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] URL]] absoluteURL]; } - (NSURL *)atomFeedURL { ! NSString *s = [NSString stringWithFormat:@"/users/%@/data/atom", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] URL]] absoluteURL]; } - (NSURL *)foafURL { ! NSString *s = [NSString stringWithFormat:@"/users/%@/data/foaf", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] URL]] absoluteURL]; } - (NSURL *)recentEntriesHttpURL { ! NSString *s = [NSString stringWithFormat:@"/users/%@/", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] URL]] absoluteURL]; } - (NSURL *)joinCommunityHttpURL { ! NSString *s = [NSString stringWithFormat:@"/community/join.bml?comm=%@", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] URL]] absoluteURL]; } - (NSURL *)leaveCommunityHttpURL { ! NSString *s = [NSString stringWithFormat:@"/community/leave.bml?comm=%@", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] URL]] absoluteURL]; } --- 107,175 ---- @end ! ! @interface LJUserEntity (PrivateLJHttpURLs) ! ! - (NSURL *)_URLWithUsernameFormat:(NSString *)format; ! ! @end ! ! ! @implementation LJUserEntity (LJHttpURLs) ! ! - (NSURL *)_URLWithUsernameFormat:(NSString *)format ! { ! NSString *string = [NSString stringWithFormat:format, [self username]]; ! NSURL *serverURL = [[[self account] server] URL]; ! return [[NSURL URLWithString:string relativeToURL:serverURL] absoluteURL]; ! } - (NSURL *)userProfileHttpURL { ! return [self _URLWithUsernameFormat:@"/userinfo.bml?user=%@"]; } - (NSURL *)memoriesHttpURL { ! return [self _URLWithUsernameFormat:@"/tools/memories.bml?user=%@"]; } - (NSURL *)toDoListHttpURL { ! return [self _URLWithUsernameFormat:@"/todo/?user=%@"]; } - (NSURL *)rssFeedURL { ! return [self _URLWithUsernameFormat:@"/users/%@/data/rss"]; } - (NSURL *)atomFeedURL { ! return [self _URLWithUsernameFormat:@"/users/%@/data/atom"]; } - (NSURL *)foafURL { ! return [self _URLWithUsernameFormat:@"/users/%@/data/foaf"]; } - (NSURL *)recentEntriesHttpURL { ! return [self _URLWithUsernameFormat:@"/users/%@/"]; } + @end + + + @implementation LJFriend (LJHttpURLs) + - (NSURL *)joinCommunityHttpURL { ! return [self _URLWithUsernameFormat:@"/community/join.bml?comm=%@"]; } - (NSURL *)leaveCommunityHttpURL { ! return [self _URLWithUsernameFormat:@"/community/leave.bml?comm=%@"]; } Index: LJHttpURLs.h =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJHttpURLs.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LJHttpURLs.h 24 Feb 2004 23:53:54 -0000 1.2 --- LJHttpURLs.h 28 Jul 2004 05:38:20 -0000 1.3 *************** *** 27,50 **** #import <Foundation/Foundation.h> ! #import "LJServer.h" ! #import "LJAccount.h" #import "LJJournal.h" ! #import "LJEntry.h" ! #import "LJEntrySummary.h" #import "LJGroup.h" #import "LJFriend.h" ! /*! ! @category LJAccount(LJHttpURLs) ! */ ! @interface LJAccount (LJHttpURLs) ! /*! ! @method userProfileHttpURL ! @abstract Returns the URL of the receiver's user profile webpage. ! */ ! - (NSURL *)userProfileHttpURL; ! - (NSURL *)memoriesHttpURL; ! - (NSURL *)toDoListHttpURL; ! @end /*! --- 27,39 ---- #import <Foundation/Foundation.h> ! #import "LJJournal.h" ! #import "LJEntryRoot.h" #import "LJGroup.h" + #import "LJUserEntity.h" #import "LJFriend.h" ! ! @class LJJournal, LJEntryRoot, LJGroup, LJUserEntity, LJFriend; /*! *************** *** 74,77 **** --- 63,67 ---- @end + /*! @category LJEntryRoot(LJHttpURLs) *************** *** 91,94 **** --- 81,85 ---- @end + /*! @category LJGroup(LJHttpURLs) *************** *** 106,122 **** @end /*! ! @category LJFriend(LJHttpURLs) */ ! @interface LJFriend (LJHttpURLs) /*! ! @method userProfileHttpURL @abstract Returns the URL of the receiver's user profile page. */ - (NSURL *)userProfileHttpURL; - (NSURL *)memoriesHttpURL; - (NSURL *)toDoListHttpURL; - (NSURL *)rssFeedURL; - (NSURL *)atomFeedURL; - (NSURL *)foafURL; /*! --- 97,137 ---- @end + /*! ! @category LJUserEntity(LJHttpURLs) */ ! @interface LJUserEntity (LJHttpURLs) /*! ! @method userProfileHttpURL @abstract Returns the URL of the receiver's user profile page. */ - (NSURL *)userProfileHttpURL; + /*! + @method memoriesHttpURL + @abstract Returns the URL of the receiver's memories page. + */ - (NSURL *)memoriesHttpURL; + /*! + @method toDoListHttpURL + @abstract Returns the URL of the receiver's to do list page. + */ - (NSURL *)toDoListHttpURL; + /*! + @method rssFeedURL + @abstract Returns the URL of the receiver's RSS feed. + */ - (NSURL *)rssFeedURL; + /*! + @method atomFeedURL + @abstract Returns the URL of the receiver's Atom feed. + */ - (NSURL *)atomFeedURL; + /*! + @method foafURL + @abstract Returns the URL of the receiver's FOAF information. + @discussion + If the user has set an external FOAF URL this method will NOT reflect that + preference. + */ - (NSURL *)foafURL; /*! *************** *** 125,129 **** */ - (NSURL *)recentEntriesHttpURL; - (NSURL *)joinCommunityHttpURL; - (NSURL *)leaveCommunityHttpURL; ! @end --- 140,159 ---- */ - (NSURL *)recentEntriesHttpURL; + @end + + + /*! + @category LJFriend(LJHttpURLs) + */ + @interface LJFriend (LJHttpURLs) + /*! + @method joinCommunityHttpURL + @abstract Returns the URL of the receiver's join community page. + */ - (NSURL *)joinCommunityHttpURL; + /*! + @method leaveCommunityHttpURL + @abstract Returns the URL of the receiver's leave community page. + */ - (NSURL *)leaveCommunityHttpURL; ! @end \ No newline at end of file --- NEW FILE: LJUserEntity.m --- /* LJKit: an Objective-C implementation of the LiveJournal client protocol Copyright (C) 2002-2003 Benjamin Peter Ragheb This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA You may contact the author via email at be...@li.... */ #import "LJUserEntity.h" #import "Miscellaneous.h" @implementation LJUserEntity - (void)dealloc { [_username release]; [_fullname release]; [super dealloc]; } - (NSString *)username { return _username; } - (void)_setUsername:(NSString *)newUsername { SafeSetString(&_username, [newUsername lowercaseString]); } - (NSString *)fullname { return _fullname; } - (void)_setFullname:(NSString *)newFullname { SafeSetString(&_fullname,newFullname); } - (LJAccount *)account { return nil; } @end --- NEW FILE: LJUserEntity_Private.h --- /* LJKit: an Objective-C implementation of the LiveJournal client protocol Copyright (C) 2002-2004 Benjamin Peter Ragheb This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA You may contact the author via email at be...@li.... */ #import "LJUserEntity.h" @interface LJUserEntity (FrameworkPrivate) - (void)_setUsername:(NSString *)newUsername; - (void)_setFullname:(NSString *)newFullname; - (LJAccount *)account; @end Index: LJServer.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJServer.m,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** LJServer.m 9 Apr 2004 04:00:58 -0000 1.8 --- LJServer.m 28 Jul 2004 05:38:20 -0000 1.9 *************** *** 243,246 **** --- 243,249 ---- } + + #define STREAM_BUFFER_SIZE 256 + - (NSDictionary *)getReplyForMode:(NSString *)mode parameters:(NSDictionary *)parameters { *************** *** 252,256 **** NSString *tmpString; UInt32 statusCode; ! UInt8 bytes[64]; // Compile HTTP POST variables into a data object. --- 255,259 ---- NSString *tmpString; UInt32 statusCode; ! UInt8 bytes[STREAM_BUFFER_SIZE]; // Compile HTTP POST variables into a data object. *************** *** 268,300 **** CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Content-Length"), (CFStringRef)tmpString); ! // Connect to the server. ! stream = CFReadStreamCreateForHTTPRequest(kCFAllocatorDefault, request); ! if (gProxyInfo) { ! CFReadStreamSetProperty(stream, kCFStreamPropertyHTTPProxy, gProxyInfo); ! } ! CFReadStreamOpen(stream); ! ! // Build an HTTP response from the data read. ! response = CFHTTPMessageCreateEmpty(kCFAllocatorDefault, FALSE); ! while (bytesRead = CFReadStreamRead(stream, bytes, 64)) { ! if (bytesRead == -1) { ! CFStreamError err = CFReadStreamGetError(stream); ! [[_account _exceptionWithFormat:@"LJStreamError_%d_%d", err.domain, err.error] raise]; ! } else if (!CFHTTPMessageAppendBytes(response, bytes, bytesRead)) { ! CFReadStreamClose(stream); ! [[_account _exceptionWithName:@"LJHTTPParseError"] raise]; ! } ! } ! statusCode = CFHTTPMessageGetResponseStatusCode(response); ! if (statusCode == 200) { ! CFDataRef responseData = CFHTTPMessageCopyBody(response); ! replyDictionary = ParseLJReplyData((NSData *)responseData); ! if (responseData) CFRelease(responseData); ! } else { ! [[_account _exceptionWithFormat:@"LJHTTPStatusError_%d", statusCode] raise]; ! } ! if (stream) CFRelease(stream); ! if (response) CFRelease(response); ! if (request) CFRelease(request); return replyDictionary; } --- 271,303 ---- CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Content-Length"), (CFStringRef)tmpString); ! // Connect to the server. ! stream = CFReadStreamCreateForHTTPRequest(kCFAllocatorDefault, request); ! if (gProxyInfo) { ! CFReadStreamSetProperty(stream, kCFStreamPropertyHTTPProxy, gProxyInfo); ! } ! CFReadStreamOpen(stream); ! ! // Build an HTTP response from the data read. ! response = CFHTTPMessageCreateEmpty(kCFAllocatorDefault, FALSE); ! while (bytesRead = CFReadStreamRead(stream, bytes, STREAM_BUFFER_SIZE)) { ! if (bytesRead == -1) { ! CFStreamError err = CFReadStreamGetError(stream); ! [[_account _exceptionWithFormat:@"LJStreamError_%d_%d", err.domain, err.error] raise]; ! } else if (!CFHTTPMessageAppendBytes(response, bytes, bytesRead)) { ! CFReadStreamClose(stream); ! [[_account _exceptionWithName:@"LJHTTPParseError"] raise]; ! } ! } ! statusCode = CFHTTPMessageGetResponseStatusCode(response); ! if (statusCode == 200) { ! CFDataRef responseData = CFHTTPMessageCopyBody(response); ! replyDictionary = ParseLJReplyData((NSData *)responseData); ! if (responseData) CFRelease(responseData); ! } else { ! [[_account _exceptionWithFormat:@"LJHTTPStatusError_%d", statusCode] raise]; ! } ! if (stream) CFRelease(stream); ! if (response) CFRelease(response); ! if (request) CFRelease(request); return replyDictionary; } Index: LJJournal.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJJournal.m,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** LJJournal.m 9 Apr 2004 03:30:09 -0000 1.4 --- LJJournal.m 28 Jul 2004 05:38:20 -0000 1.5 *************** *** 280,285 **** NSCalendarDate *date = [[NSCalendarDate alloc] initWithString:key calendarFormat:@"%Y-%m-%d"]; if (date) { ! NSNumber *count = [NSNumber numberWithInt:[[reply objectForKey:key] intValue]]; ! [workingCounts setObject:count forKey:date]; [date release]; } --- 280,285 ---- NSCalendarDate *date = [[NSCalendarDate alloc] initWithString:key calendarFormat:@"%Y-%m-%d"]; if (date) { ! int c = [[reply objectForKey:key] intValue]; ! [workingCounts setObject:[NSNumber numberWithInt:c] forKey:date]; [date release]; } Index: LJAccount.h =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJAccount.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** LJAccount.h 9 Apr 2004 04:00:58 -0000 1.4 --- LJAccount.h 28 Jul 2004 05:38:20 -0000 1.5 *************** *** 24,27 **** --- 24,28 ---- #import <Cocoa/Cocoa.h> + #import <LJKit/LJUserEntity.h> @class LJServer, LJMoods, LJJournal; *************** *** 148,154 **** to store client specific information with the account. */ ! @interface LJAccount : NSObject <NSCoding> { - NSString *_username, *_fullname; NSMenu *_menu; NSArray *_journalArray; --- 149,154 ---- to store client specific information with the account. */ ! @interface LJAccount : LJUserEntity <NSCoding> { NSMenu *_menu; NSArray *_journalArray; *************** *** 285,307 **** /*! - @method username - @abstract Returns the username associated with the receiver. - @discussion - This property is preserved during archiving. - */ - - (NSString *)username; - - /*! - @method fullname - @abstract Returns full name associated with the receiver. - @discussion - Returns the user's long name as reported by the server. If the receiver - has never been logged in, this method will return the username. - - This property is preserved during archiving. - */ - - (NSString *)fullname; - - /*! @method server @abstract Returns the LJServer object used by the receiver. --- 285,288 ---- Index: LJEntry_Metadata.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJEntry_Metadata.m,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** LJEntry_Metadata.m 14 May 2003 05:39:43 -0000 1.1.1.1 --- LJEntry_Metadata.m 28 Jul 2004 05:38:20 -0000 1.2 *************** *** 25,28 **** --- 25,30 ---- @implementation LJEntry (Metadata) + // Generic Property Access + - (void)setString:(NSString *)string forProperty:(NSString *)property { *************** *** 49,52 **** --- 51,56 ---- } + // Specific Property Access + - (NSString *)currentMood { *************** *** 120,122 **** --- 124,168 ---- } + - (BOOL)hasUnknown8bitData + { + return [self booleanForProperty:@"unknown8bit"]; + } + + - (unichar)optionScreenReplies + { + return [[_properties objectForKey:@"opt_screening"] characterAtIndex:0]; + } + + - (BOOL)hasScreenedReplies + { + return [self booleanForProperty:@"hasscreened"]; + } + + - (int)revisionNumber + { + return [[_properties objectForKey:@"revnum"] intValue]; + } + + - (NSDate *)revisionDate + { + int unixtime = [[_properties objectForKey:@"revtime"] intValue]; + return [NSDate dateWithTimeIntervalSince1970:unixtime]; + } + + - (NSDate *)commentsAlteredDate + { + int unixtime = [[_properties objectForKey:@"commentalter"] intValue]; + return [NSDate dateWithTimeIntervalSince1970:unixtime]; + } + + - (NSString *)syndicatedItemID + { + return [self stringForProperty:@"syn_id"]; + } + + - (NSURL *)syndicatedItemURL + { + return [NSURL URLWithString:[_properties objectForKey:@"syn_link"]]; + } + @end Index: LJEntry_Metadata.h =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJEntry_Metadata.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** LJEntry_Metadata.h 14 May 2003 05:39:43 -0000 1.1.1.1 --- LJEntry_Metadata.h 28 Jul 2004 05:38:20 -0000 1.2 *************** *** 112,116 **** /*! ! @method setOptionsNoComments: @abstract Set the don't allow comments setting of the receiver. @discussion --- 112,116 ---- /*! ! @method setOptionNoComments: @abstract Set the don't allow comments setting of the receiver. @discussion *************** *** 167,169 **** --- 167,210 ---- - (void)setOptionNoEmail:(BOOL)flag; + /*! + @method hasUnknown8bitData + @abstract Post contains unknown 8-bit data. + */ + - (BOOL)hasUnknown8bitData; + + /*! + @method optionScreenReplies + */ + - (unichar)optionScreenReplies; + + /*! + @method hasScreenedReplies + */ + - (BOOL)hasScreenedReplies; + + /*! + @method revisionNumber + */ + - (int)revisionNumber; + + /*! + @method revisionDate + */ + - (NSDate *)revisionDate; + + /*! + @method commentsAlteredDate + */ + - (NSDate *)commentsAlteredDate; + + /*! + @method syndicatedItemID + */ + - (NSString *)syndicatedItemID; + + /*! + @method syndicatedItemURL + */ + - (NSURL *)syndicatedItemURL; + @end Index: LJAccount.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJAccount.m,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** LJAccount.m 9 Apr 2004 04:00:58 -0000 1.7 --- LJAccount.m 28 Jul 2004 05:38:20 -0000 1.8 *************** *** 30,33 **** --- 30,34 ---- #import "LJAccount_EditFriends.h" + #import "LJUserEntity_Private.h" #import "LJAccount_Private.h" #import "LJJournal_Private.h" *************** *** 62,67 **** #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3 ! - (void)willChangeValueForKey:(id)key { } ! - (void)didChangeValueForKey:(id)key { } #endif --- 63,68 ---- #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3 ! - (void)willChangeValueForKey:(id)key {} ! - (void)didChangeValueForKey:(id)key {} #endif *************** *** 204,220 **** } - (id)initWithUsername:(NSString *)username { NSURL *defaultURL; - LJJournal *journal; if ([self init]) { NSParameterAssert(username); ! _username = [[username lowercaseString] retain]; ! _fullname = [_username copy]; defaultURL = [NSURL URLWithString:@"http://www.livejournal.com"]; _server = [[LJServer alloc] initWithURL:defaultURL account:self]; - journal = [LJJournal _journalWithName:_username account:self]; - _journalArray = [[NSArray alloc] initWithObjects:&journal count:1]; } return self; --- 205,229 ---- } + - (void)_setUsername:(NSString *)newUsername + { + LJJournal *journal; + + [super _setUsername:newUsername]; + if ([self username]) { + journal = [LJJournal _journalWithName:[self username] account:self]; + _journalArray = [[NSArray alloc] initWithObjects:&journal count:1]; + } + } + - (id)initWithUsername:(NSString *)username { NSURL *defaultURL; if ([self init]) { NSParameterAssert(username); ! [self _setUsername:username]; ! [self _setFullname:username]; defaultURL = [NSURL URLWithString:@"http://www.livejournal.com"]; _server = [[LJServer alloc] initWithURL:defaultURL account:self]; } return self; *************** *** 276,281 **** object:self]; // General account variables: - [_username release]; - [_fullname release]; [_server release]; [_menu release]; --- 285,288 ---- *************** *** 324,335 **** } ! - (NSString *)username ! { ! return _username; ! } ! ! - (NSString *)fullname { ! return _fullname; } --- 331,337 ---- } ! - (LJAccount *)account { ! return self; } *************** *** 481,485 **** loginInfo = [[NSDictionary alloc] initWithObjectsAndKeys: MD5HexDigest(password), @"hpassword", ! _username, @"user", @"1", @"ver", nil]; [_server setLoginInfo:loginInfo]; [loginInfo release]; --- 483,487 ---- loginInfo = [[NSDictionary alloc] initWithObjectsAndKeys: MD5HexDigest(password), @"hpassword", ! [self username], @"user", @"1", @"ver", nil]; [_server setLoginInfo:loginInfo]; [loginInfo release]; *************** *** 508,512 **** NS_ENDHANDLER // get the full name of the account ! _fullname = [[reply objectForKey:@"name"] retain]; // get the login message, if present _loginMessage = [[reply objectForKey:@"message"] retain]; --- 510,514 ---- NS_ENDHANDLER // get the full name of the account ! [self _setFullname:[reply objectForKey:@"name"]]; // get the login message, if present _loginMessage = [[reply objectForKey:@"message"] retain]; *************** *** 674,678 **** int p = [[serverURL port] intValue]; return [NSString stringWithFormat:@"%@@%@:%u", ! _username, [serverURL host], (p != 0 ? p : 80)]; } --- 676,680 ---- int p = [[serverURL port] intValue]; return [NSString stringWithFormat:@"%@@%@:%u", ! [self username], [serverURL host], (p != 0 ? p : 80)]; } Index: LJEntryRoot.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJEntryRoot.m,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LJEntryRoot.m 13 Mar 2004 08:40:46 -0000 1.3 --- LJEntryRoot.m 28 Jul 2004 05:38:20 -0000 1.4 *************** *** 40,43 **** --- 40,47 ---- @"LJEntryDidNotRemoveFromJournal"; + @interface LJEntryRoot (ClassPrivate) + - (void)_setSecurityMode:(int)newMode; + @end + @implementation LJEntryRoot *************** *** 67,76 **** obj = [info objectForKey:[prefix stringByAppendingString:@"security"]]; if (obj == nil || [obj isEqualToString:@"public"]) { ! _security = LJPublicSecurityMode; } else if ([obj isEqualToString:@"private"]) { ! _security = LJPrivateSecurityMode; } else if ([obj isEqualToString:@"usemask"]) { ! _security = ((_allowGroupMask == 1) ? LJFriendSecurityMode ! : LJGroupSecurityMode); } else { NSAssert1(NO, @"Unknown entry security mode: %@", obj); --- 71,80 ---- obj = [info objectForKey:[prefix stringByAppendingString:@"security"]]; if (obj == nil || [obj isEqualToString:@"public"]) { ! [self _setSecurityMode:LJPublicSecurityMode]; } else if ([obj isEqualToString:@"private"]) { ! [self _setSecurityMode:LJPrivateSecurityMode]; } else if ([obj isEqualToString:@"usemask"]) { ! [self _setSecurityMode:(_allowGroupMask == 1) ? LJFriendSecurityMode ! : LJGroupSecurityMode]; } else { NSAssert1(NO, @"Unknown entry security mode: %@", obj); *************** *** 170,173 **** --- 174,178 ---- } + - (int)securityMode { *************** *** 175,178 **** --- 180,190 ---- } + + - (void)_setSecurityMode:(int)newMode + { + _security = newMode; + } + + - (BOOL)accessAllowedForGroup:(LJGroup *)group { Index: LJFriend.h =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJFriend.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LJFriend.h 10 Jan 2004 08:39:18 -0000 1.2 --- LJFriend.h 28 Jul 2004 05:38:20 -0000 1.3 *************** *** 21,24 **** --- 21,25 ---- #import <Cocoa/Cocoa.h> + #import <LJKit/LJUserEntity.h> @class LJAccount, LJGroup; *************** *** 47,54 **** @abstract Represents a LiveJournal friend. */ ! @interface LJFriend : NSObject <NSCoding> { LJAccount *_account; - NSString *_username, *_fullname; NSCalendarDate *_birthDate; NSColor *_fgColor, *_bgColor, *_fgColorForYou, *_bgColorForYou; --- 48,54 ---- @abstract Represents a LiveJournal friend. */ ! @interface LJFriend : LJUserEntity <NSCoding> { LJAccount *_account; NSCalendarDate *_birthDate; NSColor *_fgColor, *_bgColor, *_fgColorForYou, *_bgColorForYou; *************** *** 66,84 **** /*! - @method username - @abstract Obtain the username of the receiver. - */ - - (NSString *)username; - - /*! - @method fullname - @abstract Obtain the full name of the receiver. - @discussion - Returns the receiver's full name, as reported by the server. If not - available, this method returns the receiver's username. - */ - - (NSString *)fullname; - - /*! @method birthDate @abstract Obtain the birthdate of the receiver. --- 66,69 ---- Index: LJJournal.h =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJJournal.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LJJournal.h 10 Jan 2004 08:40:47 -0000 1.2 --- LJJournal.h 28 Jul 2004 05:38:20 -0000 1.3 *************** *** 100,104 **** /*! ! @method getEntriesLastN:beforeDate: @abstract Obtain an array of the n most recent entries before a specified date. @param n The number of entries to download. --- 100,104 ---- /*! ! @method getEntriesLastN: @abstract Obtain an array of the n most recent entries before a specified date. @param n The number of entries to download. Index: LJFriend.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJFriend.m,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LJFriend.m 10 Jan 2004 08:39:18 -0000 1.3 --- LJFriend.m 28 Jul 2004 05:38:20 -0000 1.4 *************** *** 21,24 **** --- 21,25 ---- #import "LJFriend_Private.h" + #import "LJUserEntity_Private.h" #import "LJGroup.h" #import "LJAccount_EditFriends.h" *************** *** 42,46 **** // Parse field common to friendof and getfriends modes key = [prefix stringByAppendingString:@"name"]; ! SafeSetString(&amigo->_fullname, [reply objectForKey:key]); key = [prefix stringByAppendingString:@"type"]; SafeSetString(&amigo->_accountType, [reply objectForKey:key]); --- 43,47 ---- // Parse field common to friendof and getfriends modes key = [prefix stringByAppendingString:@"name"]; ! [amigo _setFullname:[reply objectForKey:key]]; key = [prefix stringByAppendingString:@"type"]; SafeSetString(&amigo->_accountType, [reply objectForKey:key]); *************** *** 150,155 **** LJFriend *amigo = [friends member:[reply objectForKey:userKey]]; if (amigo) { ! NSString *fullname = [reply objectForKey:nameKey]; ! SafeSetObject(&amigo->_fullname, fullname); } else { NSLog(@"Server says friend %@ was added, but friend doesn't appear" --- 151,155 ---- LJFriend *amigo = [friends member:[reply objectForKey:userKey]]; if (amigo) { ! [amigo _setFullname:[reply objectForKey:nameKey]]; } else { NSLog(@"Server says friend %@ was added, but friend doesn't appear" *************** *** 165,170 **** NSParameterAssert(username); _account = account; ! _username = [[username lowercaseString] retain]; ! _fullname = [_username copy]; _bgColor = [[NSColor whiteColor] retain]; _fgColor = [[NSColor blackColor] retain]; --- 165,170 ---- NSParameterAssert(username); _account = account; ! [self _setUsername:username]; ! [self _setFullname:username]; _bgColor = [[NSColor whiteColor] retain]; _fgColor = [[NSColor blackColor] retain]; *************** *** 178,183 **** - (void)dealloc { - [_username release]; - [_fullname release]; [_bgColor release]; [_fgColor release]; --- 178,181 ---- *************** *** 196,209 **** if (self) { _account = [decoder decodeObjectForKey:@"LJFriendAccount"]; ! _username = [decoder decodeObjectForKey:@"LJFriendUsername"]; ! [_username retain]; ! _fullname = [decoder decodeObjectForKey:@"LJFriendFullname"]; ! [_fullname retain]; ! _birthDate = [decoder decodeObjectForKey:@"LJFriendBirthdate"]; ! [_birthDate retain]; ! _fgColor = [decoder decodeObjectForKey:@"LJFriendForegroundColor"]; ! [_fgColor retain]; ! _bgColor = [decoder decodeObjectForKey:@"LJFriendBackgroundColor"]; ! [_bgColor retain]; _fgColorForYou = [[decoder decodeObjectForKey:@"LJFriendForegroundColorForYou"] retain]; _bgColorForYou = [[decoder decodeObjectForKey:@"LJFriendBackgroundColorForYou"] retain]; --- 194,202 ---- if (self) { _account = [decoder decodeObjectForKey:@"LJFriendAccount"]; ! _username = [[decoder decodeObjectForKey:@"LJFriendUsername"] retain]; ! _fullname = [[decoder decodeObjectForKey:@"LJFriendFullname"] retain]; ! _birthDate = [[decoder decodeObjectForKey:@"LJFriendBirthdate"] retain]; ! _fgColor = [[decoder decodeObjectForKey:@"LJFriendForegroundColor"] retain]; ! _bgColor = [[decoder decodeObjectForKey:@"LJFriendBackgroundColor"] retain]; _fgColorForYou = [[decoder decodeObjectForKey:@"LJFriendForegroundColorForYou"] retain]; _bgColorForYou = [[decoder decodeObjectForKey:@"LJFriendBackgroundColorForYou"] retain]; *************** *** 242,255 **** } - - (NSString *)username - { - return _username; - } ! - (NSString *)fullname { ! return _fullname; } - (NSCalendarDate *)birthDate { --- 235,245 ---- } ! - (LJAccount *)account { ! return _account; } + - (NSCalendarDate *)birthDate { *************** *** 338,342 **** - (unsigned)hash { ! return [_username hash]; } --- 328,332 ---- - (unsigned)hash { ! return [[self username] hash]; } *************** *** 371,375 **** // editfriend_add_i_user key = [NSString stringWithFormat:@"editfriend_add_%d_user", i]; ! [parameters setObject:_username forKey:key]; // editfriend_add_i_fg key = [NSString stringWithFormat:@"editfriend_add_%d_fg", i]; --- 361,365 ---- // editfriend_add_i_user key = [NSString stringWithFormat:@"editfriend_add_%d_user", i]; ! [parameters setObject:[self username] forKey:key]; // editfriend_add_i_fg key = [NSString stringWithFormat:@"editfriend_add_%d_fg", i]; *************** *** 387,391 **** NSString *key; ! key = [NSString stringWithFormat:@"editfriend_delete_%@", _username]; [parameters setObject:@"1" forKey:key]; } --- 377,381 ---- NSString *key; ! key = [NSString stringWithFormat:@"editfriend_delete_%@", [self username]]; [parameters setObject:@"1" forKey:key]; } |
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 { |
From: Benjamin R. <be...@us...> - 2004-04-09 03:43:23
|
Update of /cvsroot/ljkit/LJKit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16383 Modified Files: LJJournal.m LJJournal_Private.h LJAccount.m Log Message: Two changes to LJAccount. First, when a new account is created with initWithUsername:, the defaultJournal is set up (previously it would be nil until the first login). Second, during login the journal objects are reused. Previously the entire journal array would be recreated. (P.S. It seems that the a copy of the journal array was leaking during login; that has been fixed.) Index: LJJournal_Private.h =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJJournal_Private.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LJJournal_Private.h 10 Jan 2004 08:28:28 -0000 1.1 --- LJJournal_Private.h 9 Apr 2004 03:30:09 -0000 1.2 *************** *** 27,30 **** --- 27,31 ---- @interface LJJournal (FrameworkPrivate) + + (LJJournal *)_journalWithName:(NSString *)name account:(LJAccount *)account; + (NSArray *)_journalArrayFromLoginReply:(NSDictionary *)reply account:(LJAccount *)account; - (id)initWithName:(NSString *)name account:(LJAccount *)account; Index: LJJournal.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJJournal.m,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LJJournal.m 16 Mar 2004 02:53:39 -0000 1.3 --- LJJournal.m 9 Apr 2004 03:30:09 -0000 1.4 *************** *** 62,65 **** --- 62,66 ---- NSMutableArray *array; NSString *name; + LJJournal *journal; int count, i; *************** *** 67,76 **** array = [NSMutableArray arrayWithCapacity:(count + 1)]; // add user's own journal (not part of login reply) ! [array addObject:[self _journalWithName:[account username] ! account:account]]; // add others, if present for (i = 1; i <= count; i++) { name = [reply objectForKey:[NSString stringWithFormat:@"access_%d", i]]; ! [array addObject:[self _journalWithName:name account:account]]; } return array; --- 68,80 ---- array = [NSMutableArray arrayWithCapacity:(count + 1)]; // add user's own journal (not part of login reply) ! [array addObject:[account defaultJournal]]; // add others, if present for (i = 1; i <= count; i++) { name = [reply objectForKey:[NSString stringWithFormat:@"access_%d", i]]; ! journal = [account journalNamed:name]; ! if (journal == nil) { ! journal = [self _journalWithName:name account:account]; ! } ! [array addObject:journal]; } return array; Index: LJAccount.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJAccount.m,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** LJAccount.m 16 Mar 2004 02:56:49 -0000 1.5 --- LJAccount.m 9 Apr 2004 03:30:09 -0000 1.6 *************** *** 201,204 **** --- 201,205 ---- { NSURL *defaultURL; + LJJournal *journal; if ([self init]) { *************** *** 208,211 **** --- 209,214 ---- defaultURL = [NSURL URLWithString:@"http://www.livejournal.com"]; _server = [[LJServer alloc] initWithURL:defaultURL account:self]; + journal = [LJJournal _journalWithName:_username account:self]; + _journalArray = [[NSArray alloc] initWithObjects:&journal count:1]; } return self; *************** *** 461,464 **** --- 464,468 ---- NSMutableDictionary *parameters; NSNotificationCenter *noticeCenter = [NSNotificationCenter defaultCenter]; + NSArray *journals; NSAssert(password != nil, @"Password must not be nil."); *************** *** 506,511 **** [_server setUseFastServers:YES]; } ! _journalArray = [LJJournal _journalArrayFromLoginReply:reply account:self]; ! [_journalArray retain]; if (loginFlags & LJGetMoodsLoginFlag) { [_moods updateMoodsWithLoginReply:reply]; --- 510,516 ---- [_server setUseFastServers:YES]; } ! journals = [LJJournal _journalArrayFromLoginReply:reply account:self]; ! [_journalArray release]; ! _journalArray = [journals retain]; if (loginFlags & LJGetMoodsLoginFlag) { [_moods updateMoodsWithLoginReply:reply]; |
From: Benjamin R. <be...@us...> - 2004-03-27 21:03:29
|
Update of /cvsroot/ljkit/LJKit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9947 Modified Files: LJServer.m LJServer.h Log Message: Moved the MAC_OS_X_VERSION_MIN_REQUIRED macros around a bit. Too much was being excluded from Jaguar. All the proxy code is safe for Jaguar, it was only the reachability monitoring code that needed to be cordoned off. This might fix the proxy troubles in Xjournal. Fraser, you'll have to test it because I don't have a proxy or the 10.2 SDK installed. (I just successfully compiled all of LJKit with 10.1 as the deployment target; I don't know if that is a good or bad sign.) Index: LJServer.h =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJServer.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** LJServer.h 16 Mar 2004 02:54:35 -0000 1.4 --- LJServer.h 27 Mar 2004 20:52:19 -0000 1.5 *************** *** 32,35 **** --- 32,36 ---- @class LJAccount; + #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 /*! @const LJServerReachabilityDidChangeNotification *************** *** 51,54 **** --- 52,56 ---- */ FOUNDATION_EXPORT NSString * const LJServerReachabilityDidChangeNotification; + #endif /*! *************** *** 102,122 **** - (BOOL)isUsingFastServers; /*! @method enableReachabilityMonitoring @abstract Enables reachability monitoring. @discussion ! Description forthcoming. */ - #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 - (void)enableReachabilityMonitoring; #endif /*! @method disableReachabilityMonitoring @abstract Disables reachability monitoring. @discussion ! Description forthcoming. */ - #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 - (void)disableReachabilityMonitoring; #endif --- 104,132 ---- - (BOOL)isUsingFastServers; + #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 /*! @method enableReachabilityMonitoring @abstract Enables reachability monitoring. @discussion ! When monitoring is enabled, LJKit posts ! LJServerReachabilityDidChangeNotification every time the reachability of the ! server changes for some reason. You can call getReachability: to determine ! the reachability of the server. ! Monitoring is only available on Mac OS X 10.3 or later. */ - (void)enableReachabilityMonitoring; #endif + #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 /*! @method disableReachabilityMonitoring @abstract Disables reachability monitoring. @discussion ! When monitoring is enabled, LJKit posts ! LJServerReachabilityDidChangeNotification every time the reachability of the ! server changes for some reason. You can call getReachability: to determine ! the reachability of the server. ! Monitoring is only available on Mac OS X 10.3 or later. */ - (void)disableReachabilityMonitoring; #endif Index: LJServer.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJServer.m,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** LJServer.m 16 Mar 2004 02:54:35 -0000 1.6 --- LJServer.m 27 Mar 2004 20:52:19 -0000 1.7 *************** *** 32,57 **** #import "URLEncoding.h" NSString * const LJServerReachabilityDidChangeNotification = @"LJServerReachabilityDidChange"; static NSString * gUserAgent = nil; ! #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 static unsigned int gStoreRefCount = 0; static SCDynamicStoreRef gStore = NULL; static SCDynamicStoreContext gStoreContext; static CFRunLoopSourceRef gRunLoopSource = NULL; - #endif static CFDictionaryRef gProxyInfo = NULL; - #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 void LJServerStoreCallback(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info); void LJServerReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkConnectionFlags flags, void *info); #endif @interface LJServer (ClassPrivate) - #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 - (void)enableProxyDetection; - (void)disableProxyDetection; - #endif - (void)updateRequestTemplate; @end --- 32,57 ---- #import "URLEncoding.h" + #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 NSString * const LJServerReachabilityDidChangeNotification = @"LJServerReachabilityDidChange"; + #endif static NSString * gUserAgent = nil; ! // Globals Required for Proxy Detection static unsigned int gStoreRefCount = 0; static SCDynamicStoreRef gStore = NULL; static SCDynamicStoreContext gStoreContext; static CFRunLoopSourceRef gRunLoopSource = NULL; static CFDictionaryRef gProxyInfo = NULL; 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 @interface LJServer (ClassPrivate) - (void)enableProxyDetection; - (void)disableProxyDetection; - (void)updateRequestTemplate; @end *************** *** 76,82 **** _account = account; // don't retain (to avoid a cycle) [self setURL:url]; - #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 [self enableProxyDetection]; - #endif } return self; --- 76,80 ---- *************** *** 90,95 **** #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 [self disableReachabilityMonitoring]; - [self disableProxyDetection]; #endif [super dealloc]; } --- 88,93 ---- #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 [self disableReachabilityMonitoring]; #endif + [self disableProxyDetection]; [super dealloc]; } *************** *** 118,125 **** if (_requestTemplate) CFRelease(_requestTemplate); _requestTemplate = NULL; - // If we were monitoring reachability, the target needs to be updated. - /* disabled for now. Jag compat. */ #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 ! if (_target != NULL) { [self disableReachabilityMonitoring]; [self enableReachabilityMonitoring]; --- 116,122 ---- 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) { [self disableReachabilityMonitoring]; [self enableReachabilityMonitoring]; *************** *** 155,159 **** } - #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 - (void)enableProxyDetection { --- 152,155 ---- *************** *** 189,192 **** --- 185,189 ---- } + #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 - (void)enableReachabilityMonitoring { *************** *** 198,202 **** --- 195,201 ---- } } + #endif + #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 - (void)disableReachabilityMonitoring { *************** *** 320,322 **** [userInfo release]; } ! #endif \ No newline at end of file --- 319,321 ---- [userInfo release]; } ! #endif |
From: Benjamin R. <be...@us...> - 2004-03-16 03:06:06
|
Update of /cvsroot/ljkit/LJKit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10668 Modified Files: LJAccount.h LJAccount.m Log Message: Added default account tracking. Index: LJAccount.h =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJAccount.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LJAccount.h 10 Jan 2004 08:34:06 -0000 1.2 --- LJAccount.h 16 Mar 2004 02:56:49 -0000 1.3 *************** *** 19,22 **** --- 19,25 ---- You may contact the author via email at be...@li.... */ + /* + 2004-03-13 [BPR] Added default account methods. + */ #import <Cocoa/Cocoa.h> *************** *** 112,116 **** /*! ! @const LJAccountDidLoginNotification @discussion Posted after an account object fails to log in. --- 115,119 ---- /*! ! @const LJAccountDidNotLoginNotification @discussion Posted after an account object fails to log in. *************** *** 184,187 **** --- 187,242 ---- + (LJAccount *)accountWithIdentifier:(NSString *)identifier; + + /*! + @method defaultAccount + @abstract Returns the default account. + @result An account reference if any exists. + @discussion + The LJAccount keeps an internal list of all known account objects. + This method will return the one designated as default. If you have + never set a default account, and arbitrary account will be returned. + This method is guaranteed not to return nil unless there are no + LJAccount objects in memory. + */ + + (LJAccount *)defaultAccount; + + /*! + @method setDefaultAccount: + @abstract Sets the default account. + @param newDefault The account to be set as the new default. + @discussion + Use this method to designate the account object to be returned by + defaultAccount. + The identifier of the selected account will be stored in the user defaults + database. As account objects are unarchived, they check their identifiers + against the defaults database. If a match is found, the unarchived object + will be registered as the default account. Thus, default account status + is maintained across executions of your application if you archive account + object instances. If you modify the defaults key directly default account + status will not be synchronized and the results are undefined. + */ + + (void)setDefaultAccount:(LJAccount *)newDefault; + + /*! + @method setDefault: + @abstract Makes the receiver the default. + @param flag YES to make the receiver the default. + @discussion + Use this method to designate the receiver to be the object returned by + defaultAccount. If flag is NO, no action is taken. + */ + - (void)setDefault:(BOOL)flag; + + /*! + @method isDefault + @abstract Determines if the receiver is the default account. + @returns YES if the receiver is the default account, NO otherwise. + @discussion + Use this method to determine if the receiver is the object returned by + defaultAccount. + */ + - (BOOL)isDefault; + + /*! @method initWithUsername: Index: LJAccount.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJAccount.m,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** LJAccount.m 11 Feb 2004 08:52:57 -0000 1.4 --- LJAccount.m 16 Mar 2004 02:56:49 -0000 1.5 *************** *** 23,26 **** --- 23,30 ---- 2004-01-10 [BPR] Changed exception handling (gets strings from main bundle, not the LJKit bundle). + 2004-02-23 [BPR] Updated initWithUsername: to call LJServer's designated initializer. + (The account field wasn't being set.) + Added method: description + 2004-03-13 [BPR] Added default account methods. */ *************** *** 98,101 **** --- 102,106 ---- } + + (NSArray *)allAccounts { *************** *** 110,124 **** } + (LJAccount *)accountWithIdentifier:(NSString *)identifier { ! LJAccount *account = gAccountListHead; ! while (account) { ! if ([[account identifier] isEqualToString:identifier]) ! return account; ! account = account->_nextAccount; } - return nil; } - (id)init --- 115,184 ---- } + + /* In Objective-C, [nil anyMessage] == nil, which makes traversing list links a breeze! */ + - (LJAccount *)_accountWithIdentifier:(NSString *)identifier + { + if ([[self identifier] isEqualToString:identifier]) { + return self; + } else { + return [_nextAccount _accountWithIdentifier:identifier]; + } + } + + + (LJAccount *)accountWithIdentifier:(NSString *)identifier { ! return [gAccountListHead _accountWithIdentifier:identifier]; ! } ! ! + (LJAccount *)defaultAccount ! { ! return gAccountListHead; ! } ! ! ! + (void)setDefaultAccount:(LJAccount *)newDefault ! { ! NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; ! ! // Must save here in case newDefault is already the list head ! [defaults setObject:[newDefault identifier] forKey:@"LJDefaultAccountIdentifier"]; ! if (newDefault != gAccountListHead) { ! LJAccount *previous = gAccountListHead; ! LJAccount *current = gAccountListHead->_nextAccount; ! ! while (current) { ! if (current == newDefault) { ! [gAccountListHead setDefault:NO]; ! // remove newDefault from the list ! previous->_nextAccount = newDefault->_nextAccount; ! // put newDefault at the front ! newDefault->_nextAccount = gAccountListHead; ! gAccountListHead = newDefault; ! return; ! } ! previous = current; ! current = current->_nextAccount; ! } ! [NSException raise:NSInternalInconsistencyException ! format:@"New proposed default account not in the list."]; ! } ! } ! ! ! - (BOOL)isDefault ! { ! return (gAccountListHead == self); ! } ! ! ! - (void)setDefault:(BOOL)flag ! { ! if (flag) { ! [LJAccount setDefaultAccount:self]; } } + - (id)init *************** *** 126,132 **** self = [super init]; if (self) { ! // add self to global linked list of accounts ! _nextAccount = gAccountListHead; ! gAccountListHead = self; } return self; --- 186,197 ---- self = [super init]; if (self) { ! // add self to global linked list of accounts. ! // can't overwrite the head because it is the default now ! if (nil == gAccountListHead) { ! gAccountListHead = self; ! } else { ! _nextAccount = gAccountListHead->_nextAccount; ! gAccountListHead->_nextAccount = self; ! } } return self; *************** *** 135,143 **** - (id)initWithUsername:(NSString *)username { if ([self init]) { NSParameterAssert(username); _username = [[username lowercaseString] retain]; _fullname = [_username copy]; ! _server = [[LJServer alloc] init]; } return self; --- 200,211 ---- - (id)initWithUsername:(NSString *)username { + NSURL *defaultURL; + if ([self init]) { NSParameterAssert(username); _username = [[username lowercaseString] retain]; _fullname = [_username copy]; ! defaultURL = [NSURL URLWithString:@"http://www.livejournal.com"]; ! _server = [[LJServer alloc] initWithURL:defaultURL account:self]; } return self; *************** *** 153,156 **** --- 221,227 ---- { if ([self init]) { + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSString *theIdentifier; + _username = [[decoder decodeObjectForKey:@"LJAccountUsername"] retain]; _fullname = [[decoder decodeObjectForKey:@"LJAccountFullname"] retain]; *************** *** 168,171 **** --- 239,247 ---- // custom info _customInfo = [[decoder decodeObjectForKey:@"LJAccountCustomInfo"] retain]; + // check defaults to see if this is supposed to be the default account + theIdentifier = [defaults stringForKey:@"LJDefaultAccountIdentifier"]; + if ([theIdentifier isEqualToString:[self identifier]]) { + [LJAccount setDefaultAccount:self]; + } } return self; *************** *** 570,574 **** - (NSString *)identifier { ! NSURL *serverURL = [_server url]; int p = [[serverURL port] intValue]; return [NSString stringWithFormat:@"%@@%@:%u", --- 646,650 ---- - (NSString *)identifier { ! NSURL *serverURL = [_server URL]; int p = [[serverURL port] intValue]; return [NSString stringWithFormat:@"%@@%@:%u", *************** *** 619,621 **** --- 695,702 ---- } + - (NSString *)description + { + return [self identifier]; + } + @end |
From: Benjamin R. <be...@us...> - 2004-03-16 03:03:48
|
Update of /cvsroot/ljkit/LJKit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10296 Modified Files: LJServer.h LJServer.m LJHttpURLs.m Log Message: Renamed -url to -URL to make LJServer KVC compliant. Index: LJHttpURLs.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJHttpURLs.m,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** LJHttpURLs.m 24 Feb 2004 23:53:54 -0000 1.4 --- LJHttpURLs.m 16 Mar 2004 02:54:35 -0000 1.5 *************** *** 28,32 **** NSString *s; s = [NSString stringWithFormat:@"/userinfo.bml?user=%@", _username]; ! return [[NSURL URLWithString:s relativeToURL:[_server url]] absoluteURL]; } --- 28,32 ---- NSString *s; s = [NSString stringWithFormat:@"/userinfo.bml?user=%@", _username]; ! return [[NSURL URLWithString:s relativeToURL:[_server URL]] absoluteURL]; } *************** *** 34,38 **** { NSString *s = [NSString stringWithFormat:@"/tools/memories.bml?user=%@", _username]; ! return [[NSURL URLWithString:s relativeToURL:[_server url]] absoluteURL]; } --- 34,38 ---- { NSString *s = [NSString stringWithFormat:@"/tools/memories.bml?user=%@", _username]; ! return [[NSURL URLWithString:s relativeToURL:[_server URL]] absoluteURL]; } *************** *** 40,44 **** { NSString *s = [NSString stringWithFormat:@"/todo/?user=%@", _username]; ! return [[NSURL URLWithString:s relativeToURL:[_server url]] absoluteURL]; } --- 40,44 ---- { NSString *s = [NSString stringWithFormat:@"/todo/?user=%@", _username]; ! return [[NSURL URLWithString:s relativeToURL:[_server URL]] absoluteURL]; } *************** *** 51,55 **** NSString *s; s = [NSString stringWithFormat:@"/users/%@/", _name]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] url]] absoluteURL]; } --- 51,55 ---- NSString *s; s = [NSString stringWithFormat:@"/users/%@/", _name]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] URL]] absoluteURL]; } *************** *** 105,109 **** { if (_itemID) { ! NSURL *baseURL = [[[_journal account] server] url]; NSString *s = [NSString stringWithFormat:@"tools/memadd.bml?journal=%@&itemid=%u", [_journal name], [self webItemID]]; --- 105,109 ---- { if (_itemID) { ! NSURL *baseURL = [[[_journal account] server] URL]; NSString *s = [NSString stringWithFormat:@"tools/memadd.bml?journal=%@&itemid=%u", [_journal name], [self webItemID]]; *************** *** 130,134 **** { NSString *s = [NSString stringWithFormat:@"/userinfo.bml?user=%@", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] url]] absoluteURL]; } --- 130,134 ---- { NSString *s = [NSString stringWithFormat:@"/userinfo.bml?user=%@", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] URL]] absoluteURL]; } *************** *** 136,140 **** { NSString *s = [NSString stringWithFormat:@"/tools/memories.bml?user=%@", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] url]] absoluteURL]; } --- 136,140 ---- { NSString *s = [NSString stringWithFormat:@"/tools/memories.bml?user=%@", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] URL]] absoluteURL]; } *************** *** 142,146 **** { NSString *s = [NSString stringWithFormat:@"/todo/?user=%@", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] url]] absoluteURL]; } --- 142,146 ---- { NSString *s = [NSString stringWithFormat:@"/todo/?user=%@", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] URL]] absoluteURL]; } *************** *** 148,152 **** { NSString *s = [NSString stringWithFormat:@"/users/%@/data/rss", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] url]] absoluteURL]; } --- 148,152 ---- { NSString *s = [NSString stringWithFormat:@"/users/%@/data/rss", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] URL]] absoluteURL]; } *************** *** 154,158 **** { NSString *s = [NSString stringWithFormat:@"/users/%@/data/atom", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] url]] absoluteURL]; } --- 154,158 ---- { NSString *s = [NSString stringWithFormat:@"/users/%@/data/atom", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] URL]] absoluteURL]; } *************** *** 160,164 **** { NSString *s = [NSString stringWithFormat:@"/users/%@/data/foaf", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] url]] absoluteURL]; } --- 160,164 ---- { NSString *s = [NSString stringWithFormat:@"/users/%@/data/foaf", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] URL]] absoluteURL]; } *************** *** 166,170 **** { NSString *s = [NSString stringWithFormat:@"/users/%@/", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] url]] absoluteURL]; } --- 166,170 ---- { NSString *s = [NSString stringWithFormat:@"/users/%@/", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] URL]] absoluteURL]; } *************** *** 172,176 **** { NSString *s = [NSString stringWithFormat:@"/community/join.bml?comm=%@", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] url]] absoluteURL]; } --- 172,176 ---- { NSString *s = [NSString stringWithFormat:@"/community/join.bml?comm=%@", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] URL]] absoluteURL]; } *************** *** 178,182 **** { NSString *s = [NSString stringWithFormat:@"/community/leave.bml?comm=%@", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] url]] absoluteURL]; } --- 178,182 ---- { NSString *s = [NSString stringWithFormat:@"/community/leave.bml?comm=%@", _username]; ! return [[NSURL URLWithString:s relativeToURL:[[_account server] URL]] absoluteURL]; } Index: LJServer.h =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJServer.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LJServer.h 27 Feb 2004 09:21:20 -0000 1.3 --- LJServer.h 16 Mar 2004 02:54:35 -0000 1.4 *************** *** 91,98 **** /*! ! @method url ! @abstract Obtain the url of host the receiver communicates with. */ ! - (NSURL *)url; /*! --- 91,98 ---- /*! ! @method URL ! @abstract Obtain the URL of host the receiver communicates with. */ ! - (NSURL *)URL; /*! Index: LJServer.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJServer.m,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** LJServer.m 27 Feb 2004 09:21:20 -0000 1.5 --- LJServer.m 16 Mar 2004 02:54:35 -0000 1.6 *************** *** 129,133 **** } ! - (NSURL *)url { return _serverURL; --- 129,133 ---- } ! - (NSURL *)URL { return _serverURL; *************** *** 212,216 **** { NSAssert(flags != NULL, @"Flags must not be NULL."); ! return SCNetworkCheckReachabilityByName([[[self url] host] UTF8String], flags); } --- 212,216 ---- { NSAssert(flags != NULL, @"Flags must not be NULL."); ! return SCNetworkCheckReachabilityByName([[[self URL] host] UTF8String], flags); } |
From: Benjamin R. <be...@us...> - 2004-03-16 03:02:51
|
Update of /cvsroot/ljkit/LJKit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10057 Modified Files: LJJournal.m Log Message: Simplified implementation of getMostRecentEntry Index: LJJournal.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJJournal.m,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LJJournal.m 10 Jan 2004 08:40:47 -0000 1.2 --- LJJournal.m 16 Mar 2004 02:53:39 -0000 1.3 *************** *** 22,25 **** --- 22,26 ---- /* 2004-01-06 [BPR] Removed calls to ImmutablizeObject() + 2004-03-01 [BPR] Simplified implementation of getMostRecentEntry */ *************** *** 220,225 **** - (LJEntry *)getMostRecentEntry { ! NSArray *array = [self getEntriesWithParameters:[self parametersForItemID:-1]]; ! return [array count] == 0 ? nil : [array objectAtIndex:0]; } --- 221,225 ---- - (LJEntry *)getMostRecentEntry { ! return [self getEntryForItemID:-1]; } |
From: <be...@us...> - 2004-03-13 08:49:31
|
Update of /cvsroot/ljkit/LJKit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv939 Modified Files: LJEntry.h LJEntry.m LJEntryRoot.h LJEntryRoot.m Log Message: Added convenience accessors for the account an entry is associated with. These methods just call journal or setJournal: as appropriate. Index: LJEntry.h =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJEntry.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LJEntry.h 10 Jan 2004 08:37:14 -0000 1.2 --- LJEntry.h 13 Mar 2004 08:40:46 -0000 1.3 *************** *** 19,22 **** --- 19,25 ---- You may contact the author via email at be...@li.... */ + /* + 2004-03-13 [BPR] Added setAccount: + */ #import <Foundation/Foundation.h> *************** *** 90,94 **** @discussion Sets the journal this entry is associated with. To cause the receiver to become ! unassociated, call set journal to nil. An exception is raised if you attempt to change the journal of a posted entry. --- 93,97 ---- @discussion Sets the journal this entry is associated with. To cause the receiver to become ! unassociated, set journal to nil. An exception is raised if you attempt to change the journal of a posted entry. *************** *** 101,104 **** --- 104,122 ---- /*! + @method setAccount: + @abstract Set the account to associate the receiver with. + @discussion + Sets the account this entry is associated with. To cause the receiver to become + unassociated, set the account to nil. An exception is raised if you attempt to + change the account of a posted entry. + + If through this method you cause the receiver to become associated with an + different account than before, and the security mode is LJGroupModeSecurity, + the set of allowed groups will be cleared, as groups have no meaning outside + of the account they exist in. + */ + - (void)setAccount:(LJAccount *)account; + + /*! @method setDate: @abstract Set the date of the receiver. Index: LJEntry.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJEntry.m,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LJEntry.m 10 Jan 2004 08:37:14 -0000 1.2 --- LJEntry.m 13 Mar 2004 08:40:46 -0000 1.3 *************** *** 19,22 **** --- 19,25 ---- You may contact the author via email at be...@li.... */ + /* + 2004-03-13 [BPR] Added setAccount: + */ #import "LJEntry_Private.h" *************** *** 136,139 **** --- 139,149 ---- } + - (void)setAccount:(LJAccount *)account + { + if ([_journal account] != account) { + [self setJournal:[account defaultJournal]]; + } + } + - (void)setDate:(NSDate *)date { Index: LJEntryRoot.h =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJEntryRoot.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LJEntryRoot.h 10 Jan 2004 08:38:14 -0000 1.2 --- LJEntryRoot.h 13 Mar 2004 08:40:46 -0000 1.3 *************** *** 19,22 **** --- 19,29 ---- You may contact the author via email at be...@li.... */ + /* + 2004-02-24 [BPR] Fixed a typo in the comments. Changed + groupsAllowedAccessArray/Set to return nil instead of raising + an exception. + 2004-03-13 [BPR] Added account method. + + */ #import <Foundation/Foundation.h> *************** *** 124,127 **** --- 131,143 ---- /*! + @method account + @abstract Obtain the account associated with the receiver. + @discussion + Returns the account that the receiver is associated with, or nil if it is + unassociated. + */ + - (LJAccount *)account; + + /*! @method posterUsername @abstract Obtain the username of the entry's poster. *************** *** 172,180 **** /*! ! @method groupsAllowdAccessMask @discussion Returns the bitmask which defines the groups allowed to access the receiver. ! If the security mode is not LJGroupSecurityMode, this value will make no ! sense. */ - (unsigned int)groupsAllowedAccessMask; --- 188,195 ---- /*! ! @method groupsAllowedAccessMask @discussion Returns the bitmask which defines the groups allowed to access the receiver. ! If the security mode is not LJGroupSecurityMode, the value is undefined. */ - (unsigned int)groupsAllowedAccessMask; *************** *** 184,191 **** @abstract Determine what groups are allowed access to the receiver. @discussion ! You cannot use this and other group security related methods on unassociated ! entries. If you try, an exception will be raised. This is because groups have no meaning outside of their account, and unassociated entries are not attached to an account. @result An NSArray of LJGroup objects. */ --- 199,206 ---- @abstract Determine what groups are allowed access to the receiver. @discussion ! If the entry is not associated with a journal, returns nil. Groups have no meaning outside of their account, and unassociated entries are not attached to an account. + If the entry is associated but no groups are allowed access, returns an empty array. @result An NSArray of LJGroup objects. */ *************** *** 196,203 **** @abstract Determine what groups are allowed access to the receiver. @discussion ! You cannot use this and other group security related methods on unassociated ! entries. If you try, an exception will be raised. This is because groups have no meaning outside of their account, and unassociated entries are not attached to an account. @result An NSSet of LJGroup objects. */ --- 211,218 ---- @abstract Determine what groups are allowed access to the receiver. @discussion ! If the entry is not associated with a journal, returns nil. Groups have no meaning outside of their account, and unassociated entries are not attached to an account. + If the entry is associated but no groups are allowed access, returns an empty set. @result An NSSet of LJGroup objects. */ Index: LJEntryRoot.m =================================================================== RCS file: /cvsroot/ljkit/LJKit/LJEntryRoot.m,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LJEntryRoot.m 10 Jan 2004 08:38:14 -0000 1.2 --- LJEntryRoot.m 13 Mar 2004 08:40:46 -0000 1.3 *************** *** 22,25 **** --- 22,26 ---- /* 2004-01-06 [BPR] Removed calls to ImmutablizeObject() + 2004-03-13 [BPR] Added account method. */ *************** *** 149,152 **** --- 150,158 ---- } + - (LJAccount *)account + { + return [_journal account]; + } + - (NSString *)posterUsername { *************** *** 189,193 **** - (NSArray *)groupsAllowedAccessArray { ! NSAssert(_journal != nil, @"Cannot use group security methods with unassociated entries."); if (_security == LJPublicSecurityMode || _security == LJFriendSecurityMode) return [[_journal account] groupArray]; --- 195,200 ---- - (NSArray *)groupsAllowedAccessArray { ! //NSAssert(_journal != nil, @"Cannot use group security methods with unassociated entries."); ! if (_journal == nil) return nil; if (_security == LJPublicSecurityMode || _security == LJFriendSecurityMode) return [[_journal account] groupArray]; |