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]; } |