Methods



accountWithIdentifier:

Abstract: Find the account with the given identifier.
+ (LJAccount *)accountWithIdentifier:(NSString *)identifier; 

The LJAccount class keeps track of all active account objects. Using this method, you can obtain a reference to the account object with the given identifier. If no matching account is found, returns nil.

Parameters

NameDescription
identifierThe identifier for the desired account object.
Result: An account reference if found, nil otherwise.

addFriend:

Abstract: Add a friend to the receiver's friends list.
- (LJFriend *)addFriendWithUsername:(NSString *)username; 


allAccounts

Abstract: Obtain an array containing all active account objects.
+ (NSArray *)allAccounts; 

The LJAccount class keeps track of all active account objects. This method returns the list in the form of an NSArray.


customInfo

Abstract: Returns a custom info dictionary for this account.
- (NSMutableDictionary *)customInfo; 

Returns a mutable dictionary object you can use to store whatever information you would like to attach to this account. All keys and values must support the NSCoding protocol.

This property is preserved during archiving.


defaultJournal

Abstract: Obtain the user's default journal.
- (LJJournal *)defaultJournal; 

A convenience method to return the user's default journal (their own).

This property is preserved during archiving.


defaultUserPictureURL

Abstract: Returns the URL of the default user picture.
- (NSURL *)defaultUserPictureURL; 

This property is preserved during archiving.


delegate

Abstract: Returns the receiver's delegate.
- (id)delegate; 


downloadFriends

Abstract: Download friends information from the server.
- (void)downloadFriends; 

Downloads the friends associated with the receiver. This method causes any changes made to LJFriend objects locally to be discarded. You can access the LJFriends objects using the friendSet or friendArray messages.


downloadGroups

Abstract: Download friend group information from the server.
- (void)downloadGroups; 

Downloads the friend groups associated with the receiver. This method causes any changes made to LJGroup objects locally to be discarded. You can access the LJGroup objects using the groupSet or groupArray messages.


friendArray

Abstract: Obtain the friends associated with the receiver.
- (NSArray *)friendArray; 

Returns a sorted NSArray containing the user's friends in the form of LJFriend objects.

This property is preserved during archiving.


friendEnumerator

Abstract: Enumerate the friends associated with the receiver.
- (NSEnumerator *)friendEnumerator; 

Returns an NSEnumerator which traverses the user's friends, returning LJFriend objects.


friendNamed:

Abstract: Returns the friend with the given name.
- (LJFriend *)friendNamed:(NSString *)username; 

This method searches both the friends and friend-ofs for the account.


friendOfArray

Abstract: Returns the friends which list the receiver as a friend.
- (NSArray *)friendOfArray; 

This property is preserved during archiving.

Result: A sorted NSArray of LJFriend objects.

friendOfEnumerator

Abstract: Enumerate the "friend of" users for the receiver.
- (NSEnumerator *)friendOfEnumerator; 

Returns an NSEnumerator which traverses users who list the receiver as a friend, returning LJFriend objects.


friendOfSet

Abstract: Returns the friends which list the receiver as a friend.
- (NSSet *)friendOfSet; 

This property is preserved during archiving.

Result: An NSSet of LJFriend objects.

friendSet

Abstract: Obtain the friends associated with the receiver.
- (NSSet *)friendSet; 

Returns an NSSet containing the user's friends in the form of LJFriend objects.

This property is preserved during archiving.


fullname

Abstract: Returns full name associated with the receiver.
- (NSString *)fullname; 

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.


getReplyForMode:parameters:

Abstract: Sends a request to the LiveJournal server.
- (NSDictionary *)getReplyForMode:(NSString *)mode parameters:(NSDictionary *)parameters; 

Sends a message to the LiveJournal server and returns the reply. This message blocks until the message is sent over the network and a reply is received.

Most LiveJournal protocol modes are handled by other classes in the LJKit, so client programs won't need to call this method directly.

If an error occurs, an exception is raised.

Parameters

NameDescription
modeThe protocol mode to use.
parametersA set of variables and values to send to the server.
Result: A set of variables and values received from the server.

groupArray

Abstract: Obtain the friend groups associated with the receiver.
- (NSArray *)groupArray; 

Returns a sorted NSArray containing the user's friend groups in the form of LJGroup objects.

This property is preserved during archiving.


groupArrayFromMask:

- (NSArray *)groupArrayFromMask:(unsigned int)groupMask; 

Returns an array of the groups defined by the given bitmask.


groupEnumerator

Abstract: Enumerate the groups associated with the receiver.
- (NSEnumerator *)groupEnumerator; 

Returns an NSEnumerator which traverses the user's groups, returning LJGroup objects.


groupMaskFromArray:

- (unsigned int)groupMaskFromArray:(NSArray *)groupArray; 

Returns the bitmask which defines the given array of groups.


groupMaskFromSet:

- (unsigned int)groupMaskFromSet:(NSSet *)groupSet; 

Returns the bitmask which defines the given set of groups.


groupSet

Abstract: Obtain the friend groups associated with the receiver.
- (NSSet *)groupSet; 

Returns an NSSet containing the user's friend groups in the form of LJGroup objects.

This property is preserved during archiving.


groupSetFromMask:

- (NSSet *)groupSetFromMask:(unsigned int)groupMask; 

Returns a set of the groups defined by the given mask.


identifier

Abstract: Returns a unique identifier for this account.
- (NSString *)identifier; 

Returns a unique identifier for the receiver. It is of the form "username@hostname:port".


initWithContentsOfFile:

Abstract: Initializes an LJAccount object from a file.
- (id)initWithContentsOfFile:(NSString *)path; 

Initializes an account object using information previously saved to a file. This method uses NSKeyedUnarchiver to read the file.

Parameters

NameDescription
pathThe path to the previously archived account object.

initWithUsername:

Abstract: Initializes an LJAccount object.
- (id)initWithUsername:(NSString *)username; 

Initializes a newly allocated LJAccount. To start communicating with the LiveJournal server you must call the loginWithPassword: method. This is the designated initializer for the class.

Parameters

NameDescription
usernameThe user's login name.

isLoggedIn

Abstract: Returns YES if the account has been logged in.
- (BOOL)isLoggedIn; 

Result: YES if the account has successfully logged in, NO otherwise.

joinedCommunityArray

Abstract: Returns the communities the receiver is a member of.
- (NSArray *)joinedCommunityArray; 

Result: A sorted NSArray of LJFriend objects.

joinedCommunitySet

Abstract: Returns the communities the receiver is a member of.
- (NSSet *)joinedCommunitySet; 

Result: An NSSet of LJFriend objects.

journalArray

Abstract: Obtain an array of LJJournal objects for this account.
- (NSArray *)journalArray; 

This method returns an array of LJJournal objects, representing the journals this account has access to post into (e.g., communities). It will always return an array with at least one element, the default journal for this account. The default journal is always at index 0.

This property is preserved during archiving.


journalMenu

Abstract: Returns an NSMenu of all journals for this account.
- (NSMenu *)journalMenu; 

Creates an NSMenu of all journals for the receivers account. Each menu item is set to represent the appropriate LJJournal object, so you may retrieve a journal by sending the representedObject message to any of the menu items.


journalNamed:

Abstract: Obtain the journal with the given name.
- (LJJournal *)journalNamed:(NSString *)name; 

Searches the user's list of journals and returns one with the given name, or nil if none match.

Result: The desired journal if found, nil otherwise.

loginMessage

Abstract: Obtain the server's login message.
- (NSString *)loginMessage; 

The server may send a message for the user after login. Your client should call this method after loginWithPassword: and if it returns a string, display the string to the user.

Result: The login message, or nil if none was available.

loginWithPassword:

Abstract: Logs in to the LiveJournal server.
- (void)loginWithPassword:(NSString *)password; 

Calls loginWithPassword:flags: with LJDefaultLoginFlags.


loginWithPassword:flags:

Abstract: Logs in to the LiveJournal server.
- (void)loginWithPassword:(NSString *)password flags:(int)loginFlags; 

Sends a login message to the server. Use a combination of the login flags to determine what features you want to download (e.g., moods, pictures, etc.).

This method causes the password to be stored in the receiver so that it can be sent to the server on subsequent messages. You must call this method before any other methods that may communicate with the server.

The password is encoded as an MD5 hex digest before it is sent to the server, in order to make it (slightly) more difficult for packet sniffers to guess your actual password.

This method also sends the client name and version to the server. The name and version is determined by your main bundle's infoDictionary. By default, it uses the values of CFBundleName and CFBundleVersion. If you wish to override one or both of these values, use the keys LJClientName and LJClientVersion. Finally, if none of these are set the client is identified as LJKit/1.0.0.

If the username/password combination is incorrect, an exception will be raised.

Parameters

NameDescription
passwordThe user's password.
loginFlagsA bitwise-OR combination of the login flag constants.

menu

Abstract: Returns the web menu provided by the server.
- (NSMenu *)menu; 

If you provided the LJGetMenuLoginFlag to the loginWithPassword:flags: method, this method will return an NSMenu object you can display in your application. Otherwise, returns nil. The menu is configured so that selection of any items will direct the system default web browser to the correct web site. Thus, all you need to do is display the menu in your interface.


moods

Abstract: Returns an LJMoods object for this account.
- (LJMoods *)moods; 

If you provided the LJGetMoodsLoginFlag to the loginWithPassword:flags: method, this method returns an LJMoods object, which represents all the moods known to the system and maps them to IDs. Otherwise, returns nil.

This property is preserved during archiving.


newGroupWithName:

Abstract: Create a new group.
- (LJGroup *)newGroupWithName:(NSString *)name; 

Use this method if you want to add a new friend group. LiveJournal limits you to a total of 30 groups; if you exceed this limit an exception will be raised.


removeFriend:

Abstract: Removes a friend from the receiver's friends list.
- (void)removeFriend:(LJFriend *)buddy; 


removeGroup:

Abstract: Removes a friend group.
- (void)removeGroup:(LJGroup *)group; 

Removes a friend group from the receiver. This method also removes all friends from the group. If you decide to cancel the operation by calling downloadGroups, remember to call downloadFriends also.

When you uploadGroups to commit this change, the server updates the groupmask of previous posts and removes references to the deleted groups. The LJKit does not attempt to simulate this behavior, as it does not "know" where relevant LJEntry objects are stored.


server

Abstract: Returns the LJServer object used by the receiver.
- (LJServer *)server; 

This property is preserved during archiving.


setDelegate:

Abstract: Sets the receiver's delegate.
- (void)setDelegate:(id)delegate; 

Sets the delegate of the receiver. The delegate is automatically registered to receive notifications if it implements the methods below.


setMoods:

Abstract: Set the LJMoods object for this account.
- (void)setMoods:(LJMoods *)moods; 

You can set the moods object before logging in, so that the mood list can be saved between sessions. If so, only new moods will be downloaded from the server, to save on bandwidth.


uploadFriends

Abstract: Upload changes to friends to the server.
- (BOOL)uploadFriends; 

Uploads the local changes to LJFriend objects to the LiveJournal server. If friends were added, their full names are obtained from the server and saved.

Result: YES if changes were made; NO if there were no changes to upload.

uploadGroups

Abstract: Upload changes to friend groups to the server.
- (BOOL)uploadGroups; 

Uploads the local changes to LJGroup objects to the LiveJournal server.

Result: YES if changes were made; NO if there were no changes to upload.

userPicturesDictionary

Abstract: Returns a dictionary of account picture keywords and URLs.
- (NSDictionary *)userPicturesDictionary; 

If you provided the LJGetPicturesLoginFlag to the loginWithPassword:flags: method, this method will return an NSDictionary mapping userpic keywords to NSURL objects. Otherwise, returns nil.

This property is preserved during archiving.


userPicturesMenu

Abstract: Returns an NSMenu of all picture keywords for the receiver.
- (NSMenu *)userPicturesMenu; 

Creates an NSMenu representing the user's picture keywords. Each menu item has the picture's URL as a its represented object, so you can retrieve the NSURL object by calling [menuItem representedObject].


userProfileHttpURL

Abstract: Returns the URL of the receiver's user profile webpage.
- (NSURL *)userProfileHttpURL; 


username

Abstract: Returns the username associated with the receiver.
- (NSString *)username; 

This property is preserved during archiving.


watchedCommunityArray

Abstract: Returns the communities the receiver is watching.
- (NSArray *)watchedCommunityArray; 

Result: A sorted NSArray of LJFriend objects.

watchedCommunitySet

Abstract: Returns the communities the receiver is watching.
- (NSSet *)watchedCommunitySet; 

Result: An NSSet of LJFriend objects.

writeToFile:

Abstract: Archives the receiver to a file.
- (BOOL)writeToFile:(NSString *)path; 

Archives the receiver to a file. This is a convenience method; it uses NSKeyedArchiver to write the file to disk. This can be used by offline clients to save account info.

Parameters

NameDescription
pathThe path to save the object to.
Result: YES on success; NO otherwise.

(Last Updated 2/17/2003)