[Flickrkit-svn] r419 - in trunk: . FlickrKit.xcodeproj Tests

fraser at speirs.org fraser at speirs.org
Fri Nov 9 16:51:22 UTC 2007


Author: fspeirs
Date: 2007-11-09 16:51:10 +0000 (Fri, 09 Nov 2007)
New Revision: 419

Added:
   trunk/FKAccountObject.h
   trunk/FKAccountObject.m
Modified:
   trunk/FKAPIUtils.m
   trunk/FKAccount-Accs.m
   trunk/FKAccount.h
   trunk/FKAccount.m
   trunk/FKEvent.h
   trunk/FKEvent.m
   trunk/FKGroup.m
   trunk/FKPhoto-Accs.m
   trunk/FKPhoto.h
   trunk/FKPhoto.m
   trunk/FKPhotoset-Accs.m
   trunk/FKPhotoset.h
   trunk/FKPhotoset.m
   trunk/FKPhotosetCreationEditRequest.h
   trunk/FKPhotosetCreationEditRequest.m
   trunk/FKTag-Accs.m
   trunk/FKTag.h
   trunk/FKTag.m
   trunk/FKUser.h
   trunk/FKUser.m
   trunk/FlickrKit.h
   trunk/FlickrKit.xcodeproj/project.pbxproj
   trunk/Tests/FKAccountTests.m
   trunk/Tests/FKPhotoTests.m
Log:
***********************************
****** SIGNIFICANT CHANGES ********
***********************************

FKAccountObject, FKPhoto and FKPhotoset
=======================================

Is a new class representing things that a Flickr user can 'own'.  It abstracts the common things between FKPhoto and FKPhotoset. In particular, the following API are now deprecated:

-[FKPhoto photoid]
-[FKPhoto setPhotoid:]
-[FKPhotoset photosetID]
-[FKPhotoset setPhotosetID:]

The replacements are:

-[FKAccountObject nsid]
-[FKAccountObject setNsid:]

Beyond a search and replace for the above API, this change SHOULD be transparent to client apps. Please report bugs if it is not.

The notion of an 'owner' is now part of FKAccountObject and is an FKUser. Clients should take care before assuming that -owner will return an FKAccount. In some cases, you'll get an FKContact (e.g. navigating from a Contact's recent photos) or an FKUser (e.g. navigating from an Explore photo).

FKUser, FKAccount and FKContact
===============================

* The notion of a -photos array has been moved from FKAccount into FKUser.
* This means that FKContacts can now have associated photos too.

* API Change: -[FKPhoto accountIsContact:] is now named -userIsContact and takes an FKUser object.

* Several other places in the API now take an FKUser instead of an FKAccount.

FKAPIUtils
==========

* Fixed a memory leak in +treeFromData:kitMethod:flickrMethod:error:
* Fixed a bug in +responseTreeFromRootTree:kitMethod:flickrMethod:error:

Other Classes
=============

* Have been updated to remove references to -photoid and -photosetID



Modified: trunk/FKAPIUtils.m
===================================================================
--- trunk/FKAPIUtils.m	2007-11-09 08:58:37 UTC (rev 418)
+++ trunk/FKAPIUtils.m	2007-11-09 16:51:10 UTC (rev 419)
@@ -113,7 +113,7 @@
 		
 		NSLog([[[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding] autorelease]);
 	}
-	return tree;
+	return [tree autorelease];
 }
 
 + (XMLTree *)responseTreeFromRootTree:(XMLTree *)tree kitMethod:(NSString *)kitMethod flickrMethod:(NSString *)flickrMethod error:(NSError **)error {
@@ -130,6 +130,8 @@
 											flickrMethod, @"FlickrMethod", nil]];
 		
 
+		return nil;
 	}
+	return rspTree;
 }
 @end

Modified: trunk/FKAccount-Accs.m
===================================================================
--- trunk/FKAccount-Accs.m	2007-11-09 08:58:37 UTC (rev 418)
+++ trunk/FKAccount-Accs.m	2007-11-09 16:51:10 UTC (rev 419)
@@ -63,18 +63,6 @@
 }
 
 //=========================================================== 
-//  photos 
-//=========================================================== 
-- (NSMutableArray *)photos {
-    return photos; 
-}
-- (void)setPhotos:(NSMutableArray *)aPhotos {
-	[aPhotos retain];
-    [photos release];
-	photos = aPhotos;
-}
-
-//=========================================================== 
 //  firstDateTaken 
 //=========================================================== 
 - (NSString *)firstDateTaken {
@@ -304,4 +292,11 @@
     [recentActions release];
     recentActions = aRecentActions;
 }
+
+- (NSMutableArray *)accountObjectsWithRecentEvents { return accountObjectsWithRecentEvents; }
+- (void)setAccountObjectsWithRecentEvents:(NSMutableArray *)newObjects {
+	[newObjects retain];
+	[accountObjectsWithRecentEvents release];
+	accountObjectsWithRecentEvents = newObjects;
+}
 @end

Modified: trunk/FKAccount.h
===================================================================
--- trunk/FKAccount.h	2007-11-09 08:58:37 UTC (rev 418)
+++ trunk/FKAccount.h	2007-11-09 16:51:10 UTC (rev 419)
@@ -453,13 +453,13 @@
 	int usedBandwidth;
 	int maxFileSize;
 	
-	NSMutableArray *photos;
 	NSMutableArray *photosets;
 	NSMutableArray *contacts;
 	NSMutableArray *contactsRecentPhotos;
 	NSMutableArray *tags;
 	NSMutableArray *publicGroups;
 	NSMutableArray *favourites;
+	NSMutableArray *accountObjectsWithRecentEvents;
 	
 	id <FKAccountDelegate> delegate;
 	id userInfo;
@@ -640,14 +640,6 @@
 - (void)setDelegate:(id <FKAccountDelegate>)newDelegate;
 
 /*!
- * @method       photoWithID:
- * @abstract     Searches the receiver and returns a photo in the receiver's photos array matching the ID
- *               or nil if not found.
- *               Obviously, have the receiver downloadPhotos first.
- */
-- (FKPhoto *)photoWithID:(NSString *)photoID;
-
-/*!
  * @method       groupWithID:
  * @abstract     Searches the receiver and returns a group in the receiver's publicGroups array matching the ID
  *               or nil if not found.
@@ -655,6 +647,14 @@
  */
 - (FKGroup *)groupWithID:(NSString *)groupid;
 
+/*!
+ * @method       photosetWithID:
+ * @abstract     Searches the receiver and returns a photoset in the receiver's photosets array matching the ID
+ *               or nil if not found.
+ *               Obviously, have the receiver downloadPhotosets first.
+ */
+- (FKPhotoset *)photosetWithID:(NSString *)setid;
+
  /*!
   * @method       accountForNsid:username:realname:
   * @abstract     Searches the receiver, its contacts and finally creates an FKUser based on the supplied parameters.
@@ -677,11 +677,11 @@
 - (NSString *)applicationSharedSecret;
 
 /*!
- * @method      accountIsContact
- * @abstract    Returns YES if the provided FKAccount is a contact of the receiver.
+ * @method      userIsContact
+ * @abstract    Returns YES if the provided FKUser is a contact of the receiver.
  * @discussion  If the receiver has not downloaded its contacts, this method returns NO.
  */
-- (BOOL)accountIsContact:(FKAccount *)otherAccount;
+- (BOOL)userIsContact:(FKUser *)otherAccount;
 
 - (FKToken *)token;
 - (void)setToken:(FKToken *)aToken;
@@ -705,8 +705,6 @@
 - (void)setFirstDateTaken:(NSString *)aFirstDateTaken;
 - (NSString *)firstDate;
 - (void)setFirstDate:(NSString *)aFirstDate;
-- (NSMutableArray *)photos;
-- (void)setPhotos:(NSMutableArray *)aPhotos;
 - (NSMutableArray *)photosets;
 - (void)setPhotosets:(NSMutableArray *)aPhotosets;
 - (NSMutableArray *)contacts;
@@ -743,8 +741,9 @@
 - (void)setFavourites:(NSMutableArray *)aFavourites;
 - (NSDictionary *)currentPhotoDownloadOptions;
 - (void)setCurrentPhotoDownloadOptions:(NSDictionary *)aCurrentPhotoDownloadOptions;
+- (NSMutableArray *)accountObjectsWithRecentEvents;
+- (void)setAccountObjectsWithRecentEvents:(NSMutableArray *)newObjects;
 
-
 #pragma mark -
 #pragma mark Event API Support
 - (NSMutableArray *)recentEvents;

Modified: trunk/FKAccount.m
===================================================================
--- trunk/FKAccount.m	2007-11-09 08:58:37 UTC (rev 418)
+++ trunk/FKAccount.m	2007-11-09 16:51:10 UTC (rev 419)
@@ -100,8 +100,9 @@
 - (void)downloadRecentActionsFromPage:(int)page synchronously:(BOOL)syncFlag;
 - (void)processRecentActionsResponse:(NSData *)data synchronously:(BOOL)syncFlag;
 
+- (NSArray *)eventsForItemTree:(XMLTree *)itemTree;
 - (FKEvent *)eventWithXMLTree:(XMLTree *)tree;
-
+- (id)objectWithXMLTree:(XMLTree *)tree;
 @end
 
 @implementation FKAccount
@@ -129,6 +130,7 @@
 	[self setPublicGroups: [NSMutableArray array]];
 	[self setRecentActions: [NSMutableArray array]];
 	[self setRecentEvents: [NSMutableArray array]];
+	[self setAccountObjectsWithRecentEvents: [NSMutableArray array]];
 	photosetsResponseDoesFullUpdate = YES;
 	return self;
 }
@@ -163,19 +165,6 @@
 
 #pragma mark -
 #pragma mark Convenience Search Accessors
-// ================================================
-// photoWithID
-// ================================================
-- (FKPhoto *)photoWithID:(NSString *)photoID {
-	int i;
-	for(i=0; i < [[self photos] count]; i++) {
-		FKPhoto *pic = [[self photos] objectAtIndex: i];
-		if([[pic photoid] isEqualToString: photoID])
-			return pic;
-	}
-	return nil;
-}
-
 // Returns a group from the -publicGroups array with the given NSID, nil if not found.
 - (FKGroup *)groupWithID:(NSString *)groupid {
 	int i;
@@ -186,6 +175,15 @@
 	return nil;
 }
 
+- (FKPhotoset *)photosetWithID:(NSString *)setid {
+	int i;
+	for(i=0; i < [[self photosets] count]; i++) {
+		if([[[[self photosets] objectAtIndex: i] nsid] isEqualToString: setid])
+			return [[self photosets] objectAtIndex: i];
+	}
+	return nil;
+}
+
 - (FKUser *)accountForNsid:(NSString *)theNsid username:(NSString *)theUsername realname:(NSString *)theRealName {
 	if([theNsid isEqualToString: [self nsid]])
 		return self;
@@ -491,11 +489,11 @@
 }
 
 /*!
- * @method      accountIsContact
- * @abstract    Returns YES if the provided FKAccount is a contact of the receiver.
+ * @method      userIsContact
+ * @abstract    Returns YES if the provided FKUser is a contact of the receiver.
  * @discussion  If the receiver has not downloaded its contacts, this method returns NO.
  */
-- (BOOL)accountIsContact:(FKAccount *)otherAccount {
+- (BOOL)userIsContact:(FKUser *)otherAccount; {
 	if([[self contacts] count] == 0) return NO;
 	int i;
 	for(i=0; i < [[self contacts] count]; i++) {
@@ -2021,7 +2019,7 @@
 								@"flickr.activity.userPhotos", @"method",
 								[self applicationKey], @"api_key",
 								[[self token] token], @"auth_token", 
-								@"2d", @"timeframe",
+								@"5d", @"timeframe",
 								@"50", @"per_page",
 								[NSString stringWithFormat: @"%d"], @"page", nil];
 	
@@ -2085,12 +2083,19 @@
 	NSMutableArray *tempItems = [NSMutableArray array]; // Use this for performance with KVO
 	for(itemIndex = 0; itemIndex < numberOfItemNodes; itemIndex++) {
 		XMLTree *itemTree = [itemsTree childAtIndex: itemIndex];
-		[tempItems addObject: [self eventWithXMLTree:itemTree]];
+		NSArray *eventsForItem = [self eventsForItemTree: itemTree];
+		int eventCounter;
+		for(eventCounter = 0; eventCounter < [eventsForItem count]; eventCounter++) {
+			[tempItems addObject: [eventsForItem objectAtIndex: eventCounter]];
+			[[self mutableArrayValueForKey: @"accountObjectsWithRecentEvents"] addObject: [eventsForItem objectAtIndex: eventCounter]];
+		}
 	}
 	[self willChangeValueForKey: @"recentEvents"];
 	[[self recentEvents] addObjectsFromArray: tempItems];
 	[self didChangeValueForKey: @"recentEvents"];
 	
+	NSLog(@"After parsing events, we now have %d events for %d objects", [[self recentEvents] count], [[self accountObjectsWithRecentEvents] count]);
+	
 	[[self delegate] accountDidDownloadRecentEvents: self moreComing: moreComing];
 	[tree release];
 	
@@ -2182,19 +2187,27 @@
 }
 
 // This method parses one <item> block
+// Events coming back from this method should have valid objects
+// and will have been inserted into that object's recentEvents array if they have.
 - (NSArray *)eventsForItemTree:(XMLTree *)itemTree {
-//	NSMutableArray *items = [NSMutableArray array];
-//	int i;
-//	for(i=0; i < [itemTree count]; i++) {
-//		FKEvent *event = [self eventWithXMLTree: [itemTree childAtIndex: i]];
-//		id eventObject = [self objectForXMLTree: itemTree];
-//		[items addObject: event];
-//	}
-//	return items;
+	XMLTree *activityTree = [itemTree childNamed: @"activity"];
+	NSMutableArray *items = [NSMutableArray array];
+	int i;
+	for(i=0; i < [activityTree count]; i++) {
+		FKEvent *event = [self eventWithXMLTree: [activityTree childAtIndex: i]];
+		id eventObject = [self objectWithXMLTree: itemTree];
+		NSLog(@"Event object for tree: %@", [eventObject description]);
+		[event setObject: eventObject];
+		[[eventObject mutableArrayValueForKey: @"recentEvents"] addObject: event];
+		[items addObject: event];
+	}
+	return items;
 }
 
 // This method parses one <event> block
+// Currently only supports the objects belonging to this account
 - (FKEvent *)eventWithXMLTree:(XMLTree *)tree {
+	NSLog(@"Event with Tree:\n%@", [tree xml]);
 	NSString *typeAttribute = [tree attributeNamed: @"type"];
 	NSString *ownerAttribute = [tree attributeNamed: @"user"];
 	NSString *ownerUsername = [tree attributeNamed: @"username"];
@@ -2203,30 +2216,28 @@
 	
 	FKUser *eventOwner = [self accountForNsid: ownerAttribute username: ownerUsername realname: @""];
 	FKEvent *event = [[FKEvent alloc] initWithEventType: [FKEvent eventTypeFromString: typeAttribute]
-												 object: nil
+												 object: nil // Filled in by caller
 												   user: eventOwner
 											  eventDate: [NSDate dateWithTimeIntervalSince1970: [eventDateString intValue]]
 												content: contentString];
+	NSLog(@"Created event: %@", [event description]);
 	return [event autorelease];
 }
 
 // Returns the Flickr Object (photo, set, etc) that the event happened to.
 - (id)objectWithXMLTree:(XMLTree *)tree {
-//	if([[tree attributeNamed: @"type"] isEqualToString: @"photoset"]) {
-//		// Since we only have access to our own photosets, we just try 
-//		return [self photosetWithID: [tree attributeNamed: @"id"]];
-//	}
-//	
-//	if([[tree attributeNamed: @"type"] isEqualToString: @"photo"]) {
-//		// First, get the owner object
-//		FKUser *objectOwner = [self accountForNsid: [tree attributeNamed: @"owner"] username: nil realname: nil];
-//		
-//		return [self photosetWithID: [tree attributeNamed: @"id"]];
-//	}
-}
-
-- (FKPhoto *)photoWithXMLTree:(XMLTree *)tree {
+	NSLog(@"Object with Tree:\n%@", [tree xml]);
+	NSLog(@"Object type: %@", [tree attributeNamed: @"type"]);
 	
+	if([[tree attributeNamed: @"type"] isEqualToString: @"photoset"]) {
+		// Since we only have access to our own photosets, we just try 
+		return [self photosetWithID: [tree attributeNamed: @"id"]];
+	}
+	if([[tree attributeNamed: @"type"] isEqualToString: @"photo"]) {
+		return [self photoWithID: [tree attributeNamed: @"id"]];
+	}
+	
+	return nil;
 }
 
 #pragma mark -
@@ -2237,7 +2248,6 @@
 	[firstDate release];
 	[photosURL release];
 	[profileURL release];
-	[photos release];
 	[photosets release];
 	[contacts release];
 	[contactsRecentPhotos release];

Added: trunk/FKAccountObject.h
===================================================================
--- trunk/FKAccountObject.h	                        (rev 0)
+++ trunk/FKAccountObject.h	2007-11-09 16:51:10 UTC (rev 419)
@@ -0,0 +1,29 @@
+//
+//  FKAccountObject.h
+//  FlickrKit
+//
+//  Created by Fraser Speirs on 09/11/2007.
+//  Copyright 2007 __MyCompanyName__. All rights reserved.
+//
+
+/*!
+ * An FKAccountObject is something that an FKAccount owns on Flickr.
+ * Current concrete examples are: FKPhoto, FKPhotoset
+ * Will be expanded in future to include collections, whenever API support for them is added.
+ */
+#import <Cocoa/Cocoa.h>
+#import "FKUser.h"
+
+ at interface FKAccountObject : NSObject {
+	FKUser *owner;                       // The flickr user that owns this object.
+	NSString *nsid;                      // The ID of the object
+	NSMutableArray *recentEvents;        // Array of FKEvents that have happened to this object
+}
+- (id)initWithNsid:(NSString *)theNsid;
+- (FKUser *)owner;
+- (void)setOwner:(FKUser *)anOwner;
+- (NSString *)nsid;
+- (void)setNsid:(NSString *)aNsid;
+- (NSMutableArray *)recentEvents;
+- (void)setRecentEvents:(NSMutableArray *)aRecentEvents;
+ at end

Added: trunk/FKAccountObject.m
===================================================================
--- trunk/FKAccountObject.m	                        (rev 0)
+++ trunk/FKAccountObject.m	2007-11-09 16:51:10 UTC (rev 419)
@@ -0,0 +1,60 @@
+//
+//  FKAccountObject.m
+//  FlickrKit
+//
+//  Created by Fraser Speirs on 09/11/2007.
+//  Copyright 2007 __MyCompanyName__. All rights reserved.
+//
+
+#import "FKAccountObject.h"
+
+
+ at implementation FKAccountObject
+- (id)initWithNsid:(NSString *)theNsid {
+	if(self = [super init]) {
+		[self setNsid: theNsid];
+		[self setRecentEvents: [NSMutableArray array]];
+	}
+	return self;
+}
+
+//=========================================================== 
+//  owner 
+//=========================================================== 
+- (FKUser *)owner { return owner; }
+- (void)setOwner:(FKUser *)anOwner {
+    [anOwner retain];
+    [owner release];
+    owner = anOwner;
+}
+
+//=========================================================== 
+//  nsid 
+//=========================================================== 
+- (NSString *)nsid { return nsid; }
+- (void)setNsid:(NSString *)aNsid {
+    [aNsid retain];
+    [nsid release];
+    nsid = aNsid;
+}
+
+//=========================================================== 
+//  recentEvents 
+//=========================================================== 
+- (NSMutableArray *)recentEvents { return recentEvents; }
+- (void)setRecentEvents:(NSMutableArray *)aRecentEvents {
+    [aRecentEvents retain];
+    [recentEvents release];
+    recentEvents = aRecentEvents;
+}
+
+//=========================================================== 
+// dealloc
+//=========================================================== 
+- (void)dealloc {
+    [owner release];
+    [nsid release];
+    [recentEvents release];
+    [super dealloc];
+}
+ at end

Modified: trunk/FKEvent.h
===================================================================
--- trunk/FKEvent.h	2007-11-09 08:58:37 UTC (rev 418)
+++ trunk/FKEvent.h	2007-11-09 16:51:10 UTC (rev 419)
@@ -31,11 +31,13 @@
 }
 
 + (FKEventType)eventTypeFromString:(NSString *)eventString;
++ (NSString *)stringForEventType:(FKEventType)evtType;
 
 - (id)initWithEventType:(FKEventType)theType object:(id)theObject user:(FKUser *)theUser eventDate:(NSDate *)theEventDate content:(NSString *)theContent;
 
 - (FKEventType)type;
 - (void)setType:(FKEventType)aType;
+- (NSString *)typeAsString;
 - (id)object;
 - (void)setObject:(id)anObject;
 - (FKUser *)user;

Modified: trunk/FKEvent.m
===================================================================
--- trunk/FKEvent.m	2007-11-09 08:58:37 UTC (rev 418)
+++ trunk/FKEvent.m	2007-11-09 16:51:10 UTC (rev 419)
@@ -8,6 +8,10 @@
 
 #import "FKEvent.h"
 @implementation FKEvent
++ (void)initialize {
+	[self setKeys: [NSArray arrayWithObject: @"type"] triggerChangeNotificationsForDependentKey: @"typeAsString"];
+}
+
 + (FKEventType)eventTypeFromString:(NSString *)eventString {
 	if([eventString isEqualToString: @"comment"])
 		return FKEventTypeComment;
@@ -21,6 +25,19 @@
 	return FKEventTypeUnknown;
 }
 
++ (NSString *)stringForEventType:(FKEventType)evtType {
+	switch(evtType) {
+		case FKEventTypeComment:
+			return @"Comment";
+		case FKEventTypeFavourite:
+			return @"Favourite";
+		case FKEventTypeNote:
+			return @"Note";
+		default:
+			return @"Unknown";
+	}
+}
+
 - (id)initWithEventType:(FKEventType)theType 
 				 object:(id)theObject
 				   user:(FKUser *)theUser
@@ -37,6 +54,14 @@
 	return self;
 }
 
+- (NSString *)description {
+	return [NSString stringWithFormat: @"Event %@: Object=%@; User: %@; Date: %@; Content:\"%@\"", 
+			[FKEvent stringForEventType: [self type]],
+			[[self object] description],
+			[[self user] description],
+			[[self eventDate] description],
+			[self content]];
+}
 
 #pragma mark -
 #pragma mark accessors
@@ -49,6 +74,10 @@
     type = aType;
 }
 
+- (NSString *)typeAsString {
+	return [FKEvent stringForEventType: [self type]];	
+}
+
 //=========================================================== 
 //  object 
 //=========================================================== 

Modified: trunk/FKGroup.m
===================================================================
--- trunk/FKGroup.m	2007-11-09 08:58:37 UTC (rev 418)
+++ trunk/FKGroup.m	2007-11-09 16:51:10 UTC (rev 419)
@@ -101,7 +101,7 @@
 #pragma mark -
 #pragma mark Adding Photos
 - (void)addPhotoToPool:(FKPhoto *)photo synchronously:(BOOL)syncFlag {
-	[self addPhotoIDToPool: [photo photoid] synchronously: syncFlag];	
+	[self addPhotoIDToPool: [photo nsid] synchronously: syncFlag];	
 }
 
 - (void)addPhotoIDToPool:(NSString *)photoID synchronously:(BOOL)syncFlag {

Modified: trunk/FKPhoto-Accs.m
===================================================================
--- trunk/FKPhoto-Accs.m	2007-11-09 08:58:37 UTC (rev 418)
+++ trunk/FKPhoto-Accs.m	2007-11-09 16:51:10 UTC (rev 419)
@@ -15,12 +15,12 @@
 //  photoid 
 //=========================================================== 
 - (NSString *)photoid {
-    return photoid;
+	NSLog(@"WARNING: [FKPhoto photoid] is deprecated in favour of superclass -[FKAccountObject nsid]. Please update your use of this API");
+    return [super nsid];
 }
 - (void)setPhotoid:(NSString *)aPhotoid {
-	[aPhotoid retain];
-	[photoid release];
-    photoid = aPhotoid;
+	NSLog(@"WARNING: [FKPhoto setPhotoid] is deprecated in favour of superclass -[FKAccountObject setNsid]. Please update your use of this API");
+	[super setNsid: aPhotoid];
 }
 
 //=========================================================== 
@@ -345,7 +345,6 @@
 // dealloc
 //=========================================================== 
 - (void)dealloc {
-	[photoid release];
 	[secret release];
 	[datePosted release];
 	[dateTaken release];

Modified: trunk/FKPhoto.h
===================================================================
--- trunk/FKPhoto.h	2007-11-09 08:58:37 UTC (rev 418)
+++ trunk/FKPhoto.h	2007-11-09 16:51:10 UTC (rev 419)
@@ -7,6 +7,7 @@
 //
 
 #import <Cocoa/Cocoa.h>
+#import "FKAccountObject.h"
 #import "FKPhotoLink.h" // For FKPhotoSize constants
 
 @class FKAccount, XMLTree, FKPhoto, FKToken;
@@ -70,8 +71,8 @@
 - (NSString *)hostname;
 @end
 
- at interface FKPhoto : NSObject {
-	NSString *photoid;
+ at interface FKPhoto : FKAccountObject {
+//	NSString *photoid;
 	NSString *secret;
 	int server;
 	BOOL isFavourite;
@@ -100,9 +101,6 @@
 	NSMutableArray *tags;
 	NSMutableArray *notes;
 	
-	// Weak reference to owner account
-	FKAccount *owner;
-	
 	// NSURLConnections
 	NSURLConnection *completeInformationConnection, *savePermissionsConnection, *saveDatesConnection;
 	NSURLConnection *thumbnailPhotoConnection, *saveTitleAndDescriptionConnection, *saveGeoDataConnection;
@@ -129,8 +127,10 @@
 }
 + (id)photoWithPhotoXMLTree: (XMLTree *)photoTree owner:(FKAccount *)ownerAccount;
 
-- (id)initWithPhotoID:(NSString *)flickrID owner:(FKAccount *)ownerAccount;
+- (id)initWithNsid:(NSString *)theNsid;
 
+- (id)initWithPhotoID:(NSString *)flickrID owner:(FKUser *)ownerAccount;
+
 - (id)initWithOwner:(FKAccount *)theOwner
 			photoID:(NSString *)thePhotoID 
 			 secret:(NSString *)theSecret
@@ -224,15 +224,9 @@
 
 // Get comments
 - (void)downloadCommentsSynchronously:(BOOL)flag;
-
-// Get/set owner
-- (FKAccount *)owner;
-- (void)setOwner:(FKAccount *)newOwner;
 @end
 
 @interface FKPhoto (Accs)
-- (NSString *)photoid;
-- (void)setPhotoid:(NSString *)aPhotoid;
 - (NSString *)secret;
 - (void)setSecret:(NSString *)aSecret;
 - (int)server;

Modified: trunk/FKPhoto.m
===================================================================
--- trunk/FKPhoto.m	2007-11-09 08:58:37 UTC (rev 418)
+++ trunk/FKPhoto.m	2007-11-09 16:51:10 UTC (rev 419)
@@ -36,10 +36,9 @@
  * the returned object.
  */
 + (id)photoWithPhotoXMLTree: (XMLTree *)photoTree owner:(FKAccount *)ownerAccount {
-	FKPhoto *photo = [[FKPhoto alloc] init];
+	FKPhoto *photo = [[FKPhoto alloc] initWithNsid:[[photoTree attributes] objectForKey: @"id"]];
 	[photo setOwner: ownerAccount];
 
-	[photo setPhotoid: [[photoTree attributes] objectForKey: @"id"]];
 	[photo setSecret: [[photoTree attributes] objectForKey: @"secret"]];
 	[photo setServer: [[[photoTree attributes] objectForKey: @"server"] intValue]];
 	[photo setTitle: [[photoTree attributes] objectForKey: @"title"]];
@@ -65,14 +64,12 @@
 // ================================================
 // -initWithPhotoID:owner:
 // ================================================
-- (id)initWithPhotoID: (NSString *)flickrID owner:(FKAccount *)ownerAccount {
-	if(![self init])
-		return nil;
-			
-	[self setHasDownloadedAdditionalInfo: NO];
-	[self setPhotoid: flickrID];
-	[self setOwner: ownerAccount];
-	//[self downloadCompleteInformation];
+- (id)initWithPhotoID: (NSString *)flickrID owner:(FKUser *)ownerAccount {
+	if(self = [self initWithNsid: flickrID]) {
+		[self setHasDownloadedAdditionalInfo: NO];
+		[self setNsid: flickrID];
+		[self setOwner: ownerAccount];
+	}
 	return self;
 }
 
@@ -89,31 +86,27 @@
 	   allowsFamily:(BOOL)photoAllowsFamily
 	  allowsFriends:(BOOL)photoAllowsFriends
 {
-	if(![self init])
-		return nil;
-
-	[self setPhotoid: thePhotoID];
-	[self setSecret: theSecret];
-	[self setServer: theServer];
-	[self setTitle: theTitle];
-	[self setDescriptionText: theDescription];
-	[self setIsPublic: isPhotoPublic];
-	[self setAllowsFamily: photoAllowsFamily];
-	[self setAllowsFriends: photoAllowsFriends];
-
+	if(self = [self initWithNsid: thePhotoID]) {
+		[self setSecret: theSecret];
+		[self setServer: theServer];
+		[self setTitle: theTitle];
+		[self setDescriptionText: theDescription];
+		[self setIsPublic: isPhotoPublic];
+		[self setAllowsFamily: photoAllowsFamily];
+		[self setAllowsFriends: photoAllowsFriends];
+	}
 	return self;
 }
 
 // ================================================
 // -init
 // ================================================
-- (id)init {
-	if(![super init])
-		return nil;
-	
-	[self setTags: [NSMutableArray array]];	
-	[self setNotes: [NSMutableArray array]];
-	[self setComments: [NSMutableArray array]];
+- (id)initWithNsid:(NSString *)theNsid {
+	if(self = [super initWithNsid: theNsid]) {
+		[self setTags: [NSMutableArray array]];	
+		[self setNotes: [NSMutableArray array]];
+		[self setComments: [NSMutableArray array]];
+	}
 	return self;
 }
 
@@ -156,7 +149,7 @@
 				break;
 		}
 
-		NSString *baseURL = [NSString stringWithFormat: @"http://static.flickr.com/%d/%@_%@%@.%@", [self server], [self photoid], [self secret], suffix, fileFormat];
+		NSString *baseURL = [NSString stringWithFormat: @"http://static.flickr.com/%d/%@_%@%@.%@", [self server], [self nsid], [self secret], suffix, fileFormat];
 		foundURL = [NSURL URLWithString: baseURL];
 	}
 	
@@ -167,8 +160,7 @@
 // returns URL for flickr page of photo
 // ================================================
 - (NSURL *)flickrPageURL {
-	//return [NSURL URLWithString: [self photoid] relativeToURL: [[self owner] photosURL]];
-	return [NSURL URLWithString: [NSString stringWithFormat: @"http://www.flickr.com/photos/%@/%@", [[self owner] nsid], [self photoid]]];
+	return [NSURL URLWithString: [NSString stringWithFormat: @"http://www.flickr.com/photos/%@/%@", [[self owner] nsid], [self nsid]]];
 }
 
 // ================================================
@@ -402,8 +394,8 @@
 	if([[self token] token])
 		[parameters setObject: [[self token] token] forKey: @"auth_token"];
 
-	if([self photoid])
-		[parameters setObject: [self photoid] forKey: @"photo_id"];
+	if([self nsid])
+		[parameters setObject: [self nsid] forKey: @"photo_id"];
 
 	if([self secret])
 		[parameters setObject: [self secret] forKey: @"secret"];
@@ -431,7 +423,7 @@
 	NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
 	[parameters setObject: @"flickr.photos.getSizes" forKey: @"method"];
 	[parameters setObject: [self applicationKey] forKey: @"api_key"];
-	[parameters setObject: [self photoid] forKey: @"photo_id"];	
+	[parameters setObject: [self nsid] forKey: @"photo_id"];	
 	
 	if([[self token] token])
 		[parameters setObject: [[self token] token] forKey: @"auth_token"];
@@ -470,7 +462,7 @@
 	[post_dict setObject: [NSString stringWithFormat:@"%d", [self commentSecurity]] forKey:@"perm_comment"];
 	[post_dict setObject: [NSString stringWithFormat:@"%d", [self metadataSecurity]] forKey:@"perm_addmeta"];
 	[post_dict setObject: @"flickr.photos.setPerms" forKey:@"method"];
-	[post_dict setObject: [self photoid] forKey:@"photo_id"];
+	[post_dict setObject: [self nsid] forKey:@"photo_id"];
 	
 	if([owner applicationKey])
 		[post_dict setObject: [owner applicationKey] forKey:@"api_key"];
@@ -532,8 +524,8 @@
 	[post_dict setObject: @"0" forKey:@"date_taken_granularity"];
 	[post_dict setObject: @"flickr.photos.setDates" forKey:@"method"];
 	
-	if([self photoid])
-		[post_dict setObject: [self photoid] forKey:@"photo_id"];
+	if([self nsid])
+		[post_dict setObject: [self nsid] forKey:@"photo_id"];
 	else
 		NSLog(@"No photoid in -[FKPhoto saveDatesToFlickrSynchronously");
 	
@@ -598,7 +590,7 @@
 		[post_dict setObject: [self descriptionText] forKey:@"description"];
 	
 	[post_dict setObject: @"flickr.photos.setMeta" forKey:@"method"];
-	[post_dict setObject: [self photoid] forKey:@"photo_id"];
+	[post_dict setObject: [self nsid] forKey:@"photo_id"];
 	
 	if([owner applicationKey])
 		[post_dict setObject: [owner applicationKey] forKey:@"api_key"];
@@ -645,7 +637,7 @@
 	NSMutableDictionary* post_dict = [[NSMutableDictionary alloc] initWithCapacity:10];
 	
 	[post_dict setObject: @"flickr.photos.geo.setLocation" forKey:@"method"];
-	[post_dict setObject: [self photoid] forKey:@"photo_id"];
+	[post_dict setObject: [self nsid] forKey:@"photo_id"];
 	
 	if([self latitude])
 		[post_dict setObject: [self latitude] forKey: @"lat"];
@@ -703,7 +695,7 @@
 	NSMutableDictionary* post_dict = [[NSMutableDictionary alloc] initWithCapacity:10];
 	
 	[post_dict setObject: @"flickr.photos.setTags" forKey:@"method"];
-	[post_dict setObject: [self photoid] forKey:@"photo_id"];
+	[post_dict setObject: [self nsid] forKey:@"photo_id"];
 	
 	if([self tags])
 		[post_dict setObject: [[self tags] componentsJoinedByString: @" "] forKey: @"tags"];
@@ -758,7 +750,7 @@
 	NSMutableDictionary* post_dict = [[NSMutableDictionary alloc] initWithCapacity:10];
 	
 	[post_dict setObject: @"flickr.photos.licenses.setLicense" forKey:@"method"];
-	[post_dict setObject: [self photoid] forKey:@"photo_id"];
+	[post_dict setObject: [self nsid] forKey:@"photo_id"];
 	
 	if([self tags])
 		[post_dict setObject: [NSString stringWithFormat: @"%d", [self license]] forKey: @"license_id"];
@@ -809,12 +801,6 @@
 	}
 }
 
-// ================================================
-// Get/set owner
-// ================================================
-- (FKAccount *)owner { return owner; }
-- (void)setOwner:(FKAccount *)newOwner { owner = newOwner; }
-
 #pragma mark -
 #pragma mark Download Comments
 - (void)downloadCommentsSynchronously:(BOOL)flag {
@@ -825,8 +811,8 @@
 	if([[self token] token])
 		[parameters setObject: [[self token] token] forKey: @"auth_token"];
 	
-	if([self photoid])
-		[parameters setObject: [self photoid] forKey: @"photo_id"];
+	if([self nsid])
+		[parameters setObject: [self nsid] forKey: @"photo_id"];
 	
 	NSURLRequest *req = [NSURLRequest requestWithURL: [FKAPIUtils methodCallURLWithParameters: [FKAPIUtils sign: parameters withSharedSecret: [[self delegate] applicationSharedSecret]]
 																					 hostname: [[self delegate] hostname]]];
@@ -934,7 +920,7 @@
 	XMLTree *photoTree = [rspTree childNamed: @"photo"];
 	NSDictionary *photoAttributes = [photoTree attributes];
 	
-	[self setPhotoid: [photoAttributes objectForKey: @"id"]];
+	[self setNsid: [photoAttributes objectForKey: @"id"]];
 	[self setSecret: [photoAttributes objectForKey: @"secret"]];
 	[self setServer: [[photoAttributes objectForKey: @"server"] intValue]];
 	[self setIsFavourite: [[photoAttributes objectForKey: @"isfavorite"] intValue] == 1];
@@ -1278,4 +1264,11 @@
 		[(<FKPhotoDelegate>)[self delegate] photoDidSaveLicense: self];
 	[tree release];
 }
+
+#pragma mark -
+#pragma mark Debugging
+- (NSString *)description {
+	return [NSString stringWithFormat: @"FKPhoto: \"%@\" {Title: \"%@\"; Owner: %@; Privacy: %d/%d/%d}", [self nsid], [self title], [[self owner] nsid], 
+			[self isPublic], [self allowsFamily], [self allowsFriends]];
+}
 @end
\ No newline at end of file

Modified: trunk/FKPhotoset-Accs.m
===================================================================
--- trunk/FKPhotoset-Accs.m	2007-11-09 08:58:37 UTC (rev 418)
+++ trunk/FKPhotoset-Accs.m	2007-11-09 16:51:10 UTC (rev 419)
@@ -14,12 +14,12 @@
 //  photosetID 
 //=========================================================== 
 - (NSString *)photosetID {
-    return photosetID;
+	NSLog(@"WARNING: -[FKPhotoset photosetID] has been deprecated in favour of superclass -[FKAccountObject nsid]. Please update.");
+    return [super nsid];
 }
 - (void)setPhotosetID:(NSString *)aPhotosetID {
-	[aPhotosetID retain];
-	[photosetID release];
-    photosetID = aPhotosetID;
+	NSLog(@"WARNING: -[FKPhotoset setPhotosetID] has been deprecated in favour of superclass -[FKAccountObject setNsid]. Please update.");
+	[super setNsid: aPhotosetID];
 }
 
 //=========================================================== 
@@ -124,7 +124,6 @@
 // dealloc
 //=========================================================== 
 - (void)dealloc {
-	[photosetID release];
     [primaryPhotoID release];
 	[title release];
     [descriptionText release];

Modified: trunk/FKPhotoset.h
===================================================================
--- trunk/FKPhotoset.h	2007-11-09 08:58:37 UTC (rev 418)
+++ trunk/FKPhotoset.h	2007-11-09 16:51:10 UTC (rev 419)
@@ -7,6 +7,7 @@
 //
 
 #import <Cocoa/Cocoa.h>
+#import "FKAccountObject.h"
 
 @class FKAccount, FKPhotoset, XMLTree, FKPhotoUploadRequest;
 
@@ -23,8 +24,7 @@
 - (NSString *)hostname;
 @end
 
- at interface FKPhotoset : NSObject {
-	NSString *photosetID;
+ at interface FKPhotoset : FKAccountObject {
 	int server;
 	int totalPhotos;
 	NSString *primaryPhotoID;
@@ -35,7 +35,6 @@
 	NSMutableArray *comments;
 	
 	id <FKPhotosetDelegate> delegate;
-	FKAccount *owner;
 	
 	NSMutableData *photoListData, *updateFlickrData, *createOnFlickrData, *commentsData;
 	NSURLConnection *photoListConnection, *updateFlickrConnection, *createOnFlickrConnection, *commentsConnection;
@@ -49,7 +48,7 @@
 						 delegate:(id <FKPhotosetDelegate>)theDelegate;
 
 // This is the initialiser that's used when downloading this set from Flickr
-- (id)initWithSetID:(NSString *)theSetID
+- (id)initWithSetID:(NSString *)theNsid
 			 server:(int)theServer
 	   primaryPhoto:(NSString *)primaryPhotoID
 			  title:(NSString *)theTitle
@@ -76,15 +75,11 @@
 - (void)downloadCommentsSynchronously:(BOOL)flag;
 - (void)processCommentsResponse:(NSData *)data;
 
-- (FKAccount *)owner;
-- (void)setOwner:(FKAccount *)newOwner;
 - (id <FKPhotosetDelegate>)delegate;
 - (void)setDelegate: (id <FKPhotosetDelegate>)newDelegate;
 @end
 
 @interface FKPhotoset (Accs)
-- (NSString *)photosetID;
-- (void)setPhotosetID:(NSString *)aSetid;
 - (int)server;
 - (void)setServer:(int)aServer;
 - (NSString *)primaryPhotoID;

Modified: trunk/FKPhotoset.m
===================================================================
--- trunk/FKPhotoset.m	2007-11-09 08:58:37 UTC (rev 418)
+++ trunk/FKPhotoset.m	2007-11-09 16:51:10 UTC (rev 419)
@@ -15,6 +15,7 @@
 #import "FKPhotoUploadRequest.h"
 #import "FKAPIUtils.h"
 #import "FKComment.h"
+#import "FKAccountObject.h"
 
 @implementation FKPhotoset
 /* Pass in the node you get from flickr.photosets.getList
@@ -57,7 +58,7 @@
 	
 	[self setHasDownloadedPhotoList: NO];
 	[self setOwner: theOwner];
-	[self setPhotosetID: theSetID];
+	[self setNsid: theSetID];
 	[self setServer: theServer];
 	[self setPrimaryPhotoID: thePrimaryPhotoID];
 	[self setTitle: theTitle];
@@ -90,7 +91,7 @@
 	
 	int i;
 	for(i=0; i < [completedRequests count]; i++) {
-		FKPhoto *photo = [[FKPhoto alloc] initWithPhotoID: [[completedRequests objectAtIndex: i] photoid]
+		FKPhoto *photo = [[FKPhoto alloc] initWithPhotoID: [[completedRequests objectAtIndex: i] nsid]
 													owner: [self owner]];
 		[[self mutableArrayValueForKey: @"photos"] addObject: [photo autorelease]];
 	}
@@ -109,9 +110,6 @@
 	return self;
 }
 
-- (FKAccount *)owner { return owner; }
-- (void)setOwner:(FKAccount *)newOwner { owner = newOwner; }
-
 - (id <FKPhotosetDelegate>)delegate { return delegate; }
 - (void)setDelegate: (id <FKPhotosetDelegate>)newDelegate { delegate = newDelegate; }
 
@@ -129,7 +127,7 @@
 
 	NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
 		@"flickr.photosets.getPhotos", @"method",
-		[self photosetID], @"photoset_id",
+		[self nsid], @"photoset_id",
 		[[self owner] applicationKey], @"api_key",
 		[[[self owner] token] token], @"auth_token", 
 		[NSString stringWithFormat: @"%d", startPage], @"page",
@@ -165,7 +163,7 @@
 - (void)downloadCommentsSynchronously:(BOOL)flag {
 	NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys: 
 								@"flickr.photosets.comments.getList", @"method",
-								[self photosetID], @"photoset_id",
+								[self nsid], @"photoset_id",
 								[[self owner] applicationKey], @"api_key", nil];
 	NSURLRequest *req = [NSURLRequest requestWithURL: [FKAPIUtils methodCallURLWithParameters: parameters hostname: [[self delegate] hostname]]];
 	

Modified: trunk/FKPhotosetCreationEditRequest.h
===================================================================
--- trunk/FKPhotosetCreationEditRequest.h	2007-11-09 08:58:37 UTC (rev 418)
+++ trunk/FKPhotosetCreationEditRequest.h	2007-11-09 16:51:10 UTC (rev 419)
@@ -97,7 +97,7 @@
 - (void)updateFlickrSynchronously;
 - (void)processUpdateFlickrResponse: (NSData *)data;
 
-- (NSURL *)addPhotoURLWithID:(NSString *)photoid;
+- (NSURL *)addPhotoURLWithID:(NSString *)nsid;
 - (void)addPhoto: (FKPhoto *)photo synchronously:(BOOL)syncFlag;
 - (void)addPhotoWithID:(NSString *)photoid synchronously:(BOOL)flag;
 - (void)bulkAddPhotoIDs:(NSArray *)photoIDs;

Modified: trunk/FKPhotosetCreationEditRequest.m
===================================================================
--- trunk/FKPhotosetCreationEditRequest.m	2007-11-09 08:58:37 UTC (rev 418)
+++ trunk/FKPhotosetCreationEditRequest.m	2007-11-09 16:51:10 UTC (rev 419)
@@ -33,7 +33,7 @@
 + (FKPhotosetCreationEditRequest *)requestWithPhotoset: (FKPhotoset *)set 
 											  delegate: (id <FKPhotosetCreationEditRequestDelegate>)del
 {
-	FKPhotosetCreationEditRequest *req = [[FKPhotosetCreationEditRequest alloc] initWithPhotosetID: [set photosetID]
+	FKPhotosetCreationEditRequest *req = [[FKPhotosetCreationEditRequest alloc] initWithPhotosetID: [set nsid]
 																						  photoids: [set photoIDs]
 																					primaryPhotoID: [set primaryPhotoID]
 																							 title: [set title]
@@ -265,17 +265,17 @@
 }
 
 - (void)addPhoto: (FKPhoto *)photo synchronously:(BOOL)syncFlag {
-	[self addPhotoWithID: [photo photoid] synchronously: syncFlag];	
+	[self addPhotoWithID: [photo nsid] synchronously: syncFlag];	
 }
 
-- (void)addPhotoWithID:(NSString *)photoid synchronously:(BOOL)flag {
-	[self setPhotoIDToAppend: photoid];
+- (void)addPhotoWithID:(NSString *)nsid synchronously:(BOOL)flag {
+	[self setPhotoIDToAppend: nsid];
 	[self setPhotoToAppend: nil];
 	
 	if(flag) {
 		NSURLResponse *resp;
 		NSError *err;
-		NSData *data = [NSURLConnection sendSynchronousRequest: [NSURLRequest requestWithURL: [self addPhotoURLWithID: photoid]] 
+		NSData *data = [NSURLConnection sendSynchronousRequest: [NSURLRequest requestWithURL: [self addPhotoURLWithID: nsid]] 
 											 returningResponse: &resp 
 														 error: &err];
 		[self processAddPhotoResponse: data];
@@ -283,7 +283,7 @@
 	else {
 		[addPhotoData release];
 		addPhotoData = [[NSMutableData data] retain];
-		addPhotoConnection = [[NSURLConnection alloc] initWithRequest: [NSURLRequest requestWithURL: [self addPhotoURLWithID: photoid]]
+		addPhotoConnection = [[NSURLConnection alloc] initWithRequest: [NSURLRequest requestWithURL: [self addPhotoURLWithID: nsid]]
 															 delegate: self];
 		NSAssert(addPhotoData != nil, @"Addphotodata is nil in addPhotoWithID:synchronously:");
 	}

Modified: trunk/FKTag-Accs.m
===================================================================
--- trunk/FKTag-Accs.m	2007-11-09 08:58:37 UTC (rev 418)
+++ trunk/FKTag-Accs.m	2007-11-09 16:51:10 UTC (rev 419)
@@ -47,10 +47,8 @@
 //=========================================================== 
 //  owner 
 //=========================================================== 
-- (FKAccount *)owner {
-    return owner; 
-}
-- (void)setOwner:(FKAccount *)anOwner {
+- (FKUser *)owner { return owner; }
+- (void)setOwner:(FKUser *)anOwner {
     owner = anOwner;
 }
 

Modified: trunk/FKTag.h
===================================================================
--- trunk/FKTag.h	2007-11-09 08:58:37 UTC (rev 418)
+++ trunk/FKTag.h	2007-11-09 16:51:10 UTC (rev 419)
@@ -8,14 +8,14 @@
 
 #import <Cocoa/Cocoa.h>
 
- at class FKAccount, XMLTree;
+ at class FKUser, FKAccount, XMLTree;
 
 @interface FKTag : NSObject {
 	int tagID;
 	NSString *rawTag;
 	NSString *formattedTag;
 	
-	FKAccount *owner;
+	FKUser *owner;
 }
 
 // Utilities to convert a tag array to and from a single string
@@ -23,12 +23,12 @@
 + (NSArray *)tagArrayFromString:(NSString *)tagString;
 
 + (FKTag *)tagWithID: (int)tagID;
-+ (id)tagWithTagXMLTree:(XMLTree *)tagTree owner: (FKAccount *)owner;
++ (id)tagWithTagXMLTree:(XMLTree *)tagTree owner: (FKUser *)owner;
 + (void)registerTag:(FKTag *)tag;
 + (FKTag *)tagForID:(int)tagID;
 + (FKTag *)tagWithTag:(FKTag *)tag;
 
-- (id)initWithTagID:(int)theTagID rawTag:(NSString *)theRawTag formattedTag:(NSString *)theFormattedTag owner:(FKAccount *)theOwner;
+- (id)initWithTagID:(int)theTagID rawTag:(NSString *)theRawTag formattedTag:(NSString *)theFormattedTag owner:(FKUser *)theOwner;
 - (NSString *)rawTagEscapedWithQuotes;
 - (NSURL *)globalTagURL;
 - (NSURL *)tagURLForUser:(FKAccount *)userAccount;
@@ -41,6 +41,6 @@
 - (void)setRawTag:(NSString *)aRawTag;
 - (NSString *)formattedTag;
 - (void)setFormattedTag:(NSString *)aFormattedTag;
-- (FKAccount *)owner;
-- (void)setOwner:(FKAccount *)anOwner;
+- (FKUser *)owner;
+- (void)setOwner:(FKUser *)anOwner;
 @end

Modified: trunk/FKTag.m
===================================================================
--- trunk/FKTag.m	2007-11-09 08:58:37 UTC (rev 418)
+++ trunk/FKTag.m	2007-11-09 16:51:10 UTC (rev 419)
@@ -54,7 +54,7 @@
 	return nil;
 }
 
-+ (id)tagWithTagXMLTree:(XMLTree *)tagTree owner: (FKAccount *)theOwner {
++ (id)tagWithTagXMLTree:(XMLTree *)tagTree owner: (FKUser *)theOwner {
 	NSDictionary *attributes = [tagTree attributes];
 	
 	NSString *formatted = [tagTree description];
@@ -95,7 +95,7 @@
 								   owner: [tag owner]] autorelease];
 }
 
-- (id)initWithTagID:(int)theTagID rawTag:(NSString *)theRawTag formattedTag:(NSString *)theFormattedTag owner:(FKAccount *)theOwner {
+- (id)initWithTagID:(int)theTagID rawTag:(NSString *)theRawTag formattedTag:(NSString *)theFormattedTag owner:(FKUser *)theOwner {
 	if(![super init])
 		return nil;
 

Modified: trunk/FKUser.h
===================================================================
--- trunk/FKUser.h	2007-11-09 08:58:37 UTC (rev 418)
+++ trunk/FKUser.h	2007-11-09 16:51:10 UTC (rev 419)
@@ -14,24 +14,44 @@
  *
  * It is specialised into FKAccount and FKContact for more particular kinds
  * of Flickr user.
+ *
+ * FKUser stubs out the FKAuthenticationProvider protocol. Subclasses must implement if sensible.
  */
 
 #import <Cocoa/Cocoa.h>
 
+ at class FKToken, FKPhoto;
 
 @interface FKUser : NSObject {
 	NSString *nsid;
 	NSString *username;
 	NSString *realname;
+	NSMutableArray *photos; // Contacts can have photos too.
 }
 
 - (id)initWithNsid:(NSString *)theNsid username:(NSString *)theUsername realname:(NSString *)theRealname;
 
+/*!
+ * @method       photoWithID:
+ * @abstract     Searches the receiver and returns a photo in the receiver's photos array matching the ID
+ *               or nil if not found.
+ *               The receiver should have its photos array populated first. Subclasses define.
+ */
+- (FKPhoto *)photoWithID:(NSString *)photoID;
+
+#pragma mark -
+#pragma mark Accessors
 - (NSString *)nsid;
 - (void)setNsid:(NSString *)aNsid;
 - (NSString *)username;
 - (void)setUsername:(NSString *)anUsername;
 - (NSString *)realname;
 - (void)setRealname:(NSString *)aRealname;
+- (NSMutableArray *)photos;
+- (void)setPhotos:(NSMutableArray *)aPhotos;
 
+- (NSString *)applicationSharedSecret;
+- (NSString *)applicationKey;
+- (FKToken *)token;
+- (NSString *)hostname;
 @end

Modified: trunk/FKUser.m
===================================================================
--- trunk/FKUser.m	2007-11-09 08:58:37 UTC (rev 418)
+++ trunk/FKUser.m	2007-11-09 16:51:10 UTC (rev 419)
@@ -7,18 +7,34 @@
 //
 
 #import "FKUser.h"
+#import "FKToken.h"
+#import "FKPhoto.h" // For FKPhotoAuthenticationProvider
 
+ at implementation FKUser
 
- at implementation FKUser
 - (id)initWithNsid:(NSString *)theNsid username:(NSString *)theUsername realname:(NSString *)theRealname {
 	if(self = [super init]) {
 		[self setNsid: theNsid];
 		[self setUsername: theUsername];
 		[self setRealname: theRealname];
+		[self setPhotos: [NSMutableArray array]];
 	}
 	return self;
 }
 
+// ================================================
+// photoWithID
+// ================================================
+- (FKPhoto *)photoWithID:(NSString *)photoID {
+	int i;
+	for(i=0; i < [[self photos] count]; i++) {
+		FKPhoto *pic = [[self photos] objectAtIndex: i];
+		if([[pic nsid] isEqualToString: photoID])
+			return pic;
+	}
+	return nil;
+}
+
 //=========================================================== 
 //  nsid 
 //=========================================================== 
@@ -48,4 +64,41 @@
     [realname release];
     realname = aRealname;
 }
- at end
+
+//=========================================================== 
+//  photos 
+//=========================================================== 
+- (NSMutableArray *)photos { return photos; }
+- (void)setPhotos:(NSMutableArray *)aPhotos {
+    [aPhotos retain];
+    [photos release];
+    photos = aPhotos;
+}
+
+- (NSString *)applicationSharedSecret { 
+	NSLog(@"applicationSharedSecret is not implemented in FKUser. Subclass must implement.");
+	return nil; 
+}
+- (NSString *)applicationKey { 
+	NSLog(@"applicationKey is not implemented in FKUser. Subclass must implement.");
+	return nil; 
+}
+
+- (FKToken *)token { 	
+	NSLog(@"token is not implemented in FKUser. Subclass must implement.");
+	return nil; 
+}
+
+- (NSString *)hostname { 
+	NSLog(@"hostname is not implemented in FKUser. Subclass must implement.");
+	return nil; 
+}
+
+- (void)dealloc {
+	[nsid release];
+	[username release];
+	[realname release];
+	[photos release];
+	[super dealloc];
+}
+ at end
\ No newline at end of file

Modified: trunk/FlickrKit.h
===================================================================
--- trunk/FlickrKit.h	2007-11-09 08:58:37 UTC (rev 418)
+++ trunk/FlickrKit.h	2007-11-09 16:51:10 UTC (rev 419)
@@ -35,3 +35,5 @@
 #import "FKComment.h"
 #import "FKPhotoset.h"
 #import "FKNote.h"
+#import "FKUser.h"
+#import "FKEvent.h"
\ No newline at end of file

Modified: trunk/FlickrKit.xcodeproj/project.pbxproj
===================================================================
--- trunk/FlickrKit.xcodeproj/project.pbxproj	2007-11-09 08:58:37 UTC (rev 418)
+++ trunk/FlickrKit.xcodeproj/project.pbxproj	2007-11-09 16:51:10 UTC (rev 419)
@@ -34,6 +34,8 @@
 		5F7FD0D40A9B867B00423F14 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; };
 		5F7FD0D50A9B867C00423F14 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D69BFE84028FC02AAC07 /* Foundation.framework */; };
 		5F7FD0E10A9B86B400423F14 /* FKUploadTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F0F857908702D7B00C5DA02 /* FKUploadTests.m */; };
+		5F8DA0DC0CE4A36600F7DBC4 /* FKAccountObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 5F8DA0DA0CE4A36600F7DBC4 /* FKAccountObject.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		5F8DA0DD0CE4A36600F7DBC4 /* FKAccountObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F8DA0DB0CE4A36600F7DBC4 /* FKAccountObject.m */; };
 		5FB24D8A087AF2E4008B5AB5 /* XMLTree.h in Headers */ = {isa = PBXBuildFile; fileRef = 5FB24D88087AF2E4008B5AB5 /* XMLTree.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		5FB24D8B087AF2E4008B5AB5 /* XMLTree.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FB24D89087AF2E4008B5AB5 /* XMLTree.m */; };
 		5FB24FF1087C167D008B5AB5 /* FKNote.h in Headers */ = {isa = PBXBuildFile; fileRef = 5FB24FEF087C167D008B5AB5 /* FKNote.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -56,7 +58,7 @@
 		5FCC684308153884000FC95A /* FKPhotoUploadRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 5FCC684108153884000FC95A /* FKPhotoUploadRequest.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		5FCC684408153884000FC95A /* FKPhotoUploadRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FCC684208153884000FC95A /* FKPhotoUploadRequest.m */; };
 		5FCC685308153A5D000FC95A /* FKPhotoUploadRequest-Accs.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FCC685108153A5D000FC95A /* FKPhotoUploadRequest-Accs.m */; };
-		5FD405770CE1E2C2004EABDD /* FKEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 5FD405750CE1E2C2004EABDD /* FKEvent.h */; };
+		5FD405770CE1E2C2004EABDD /* FKEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 5FD405750CE1E2C2004EABDD /* FKEvent.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		5FD405780CE1E2C3004EABDD /* FKEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FD405760CE1E2C2004EABDD /* FKEvent.m */; };
 		5FD4057C0CE1E3BF004EABDD /* FKUser.h in Headers */ = {isa = PBXBuildFile; fileRef = 5FD4057A0CE1E3BF004EABDD /* FKUser.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		5FD4057D0CE1E3BF004EABDD /* FKUser.m in Sources */ = {isa = PBXBuildFile; fileRef = 5FD4057B0CE1E3BF004EABDD /* FKUser.m */; };
@@ -124,6 +126,8 @@
 		5F6E3D000818E18100D2D61B /* FKPhotoset.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FKPhotoset.h; sourceTree = "<group>"; };
 		5F7FD0B70A9B85E300423F14 /* FlickrKit Tests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "FlickrKit Tests.octest"; sourceTree = BUILT_PRODUCTS_DIR; };
 		5F7FD0B80A9B85E300423F14 /* FlickrKit Tests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "FlickrKit Tests-Info.plist"; sourceTree = "<group>"; };
+		5F8DA0DA0CE4A36600F7DBC4 /* FKAccountObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FKAccountObject.h; sourceTree = "<group>"; };
+		5F8DA0DB0CE4A36600F7DBC4 /* FKAccountObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FKAccountObject.m; sourceTree = "<group>"; };
 		5F963FA90892423B00390366 /* FKTagTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FKTagTests.h; path = Tests/FKTagTests.h; sourceTree = "<group>"; };
 		5F963FAA0892423B00390366 /* FKTagTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FKTagTests.m; path = Tests/FKTagTests.m; sourceTree = "<group>"; };
 		5FB24D88087AF2E4008B5AB5 /* XMLTree.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = XMLTree.h; sourceTree = "<group>"; };
@@ -253,49 +257,16 @@
 		08FB77AEFE84172EC02AAC07 /* Classes */ = {
 			isa = PBXGroup;
 			children = (
-				5FD4057A0CE1E3BF004EABDD /* FKUser.h */,
-				5FD4057B0CE1E3BF004EABDD /* FKUser.m */,
-				5FD405750CE1E2C2004EABDD /* FKEvent.h */,
-				5FD405760CE1E2C2004EABDD /* FKEvent.m */,
 				5FCC65600814CA5F000FC95A /* FlickrKit.h */,
-				5F18B9B70BF1D78F00F552E9 /* FKComment.h */,
-				5F18B9B80BF1D78F00F552E9 /* FKComment.m */,
 				5FB8A5DC0813FE9100EDEBC1 /* FKDefines.h */,
-				5FB24FEF087C167D008B5AB5 /* FKNote.h */,
-				5FB24FF0087C167D008B5AB5 /* FKNote.m */,
-				5F0F84260870014500C5DA02 /* FKToken.h */,
-				5F0F84270870014500C5DA02 /* FKToken.m */,
-				5FBF4E560813EDF300829423 /* FKAccount.h */,
-				5FBF4E570813EDF300829423 /* FKAccount.m */,
-				5FBA6330091C0AD800CD577F /* FKContact.h */,
-				5FBA6331091C0AD800CD577F /* FKContact.m */,
-				5FCC645208142396000FC95A /* FKPhoto.h */,
-				5FCC645308142396000FC95A /* FKPhoto.m */,
-				5FCC66E308150313000FC95A /* FKTag.h */,
-				5FCC66E408150313000FC95A /* FKTag.m */,
-				5FCC684108153884000FC95A /* FKPhotoUploadRequest.h */,
-				5FCC684208153884000FC95A /* FKPhotoUploadRequest.m */,
-				5FE3542008996F2400636417 /* FKPhotosetCreationEditRequest.h */,
-				5FE3542108996F2400636417 /* FKPhotosetCreationEditRequest.m */,
-				5F6E3D000818E18100D2D61B /* FKPhotoset.h */,
-				5F1DD00C08168443003D9229 /* FKPhotoset.m */,
-				5F1C3C610C399A9300DF3E71 /* FKPhotoLink.h */,
-				5F1C3C620C399A9300DF3E71 /* FKPhotoLink.m */,
+				5F8DA1870CE4AFFB00F7DBC4 /* Authentication */,
+				5F8DA17F0CE4AF6900F7DBC4 /* People */,
+				5F8DA1860CE4AFD600F7DBC4 /* Account Objects */,
+				5F8DA18A0CE4B04700F7DBC4 /* MetaCollections */,
+				5F8DA1880CE4B01A00F7DBC4 /* Upload Templates */,
 				5FC51B8E08198B7900BDC994 /* FKUserInfoSearch.h */,
 				5FC51B8F08198B7900BDC994 /* FKUserInfoSearch.m */,
-				5FF15ECC088FD91F0055F886 /* FKAPIUtils.h */,
-				5FF15ECD088FD91F0055F886 /* FKAPIUtils.m */,
-				5FF15EDA088FD9570055F886 /* FKCategories.h */,
-				5FF15EDB088FD9570055F886 /* FKCategories.m */,
-				5F0F847A087003A000C5DA02 /* NSData Categories */,
-				5FD9A96E08807A8500E95C71 /* Accessor Categories */,
-				5FDF019F08BA61F8005983AB /* FKSIPSUtilities.h */,
-				5FDF01A008BA61F8005983AB /* FKSIPSUtilities.m */,
-				5F17F316093DABCA0080FFB1 /* FKGroup.h */,
-				5F17F317093DABCA0080FFB1 /* FKGroup.m */,
-				5FFB981609FCC22600F6A041 /* FKSocket */,
-				5F667B610B066062007CDAC0 /* FKInterestingness.h */,
-				5F667B620B066062007CDAC0 /* FKInterestingness.m */,
+				5F8DA1890CE4B02700F7DBC4 /* Utilities */,
 			);
 			name = Classes;
 			sourceTree = "<group>";
@@ -374,6 +345,90 @@
 			name = Old;
 			sourceTree = "<group>";
 		};
+		5F8DA17F0CE4AF6900F7DBC4 /* People */ = {
+			isa = PBXGroup;
+			children = (
+				5FD4057A0CE1E3BF004EABDD /* FKUser.h */,
+				5FD4057B0CE1E3BF004EABDD /* FKUser.m */,
+				5FBF4E560813EDF300829423 /* FKAccount.h */,
+				5FBF4E570813EDF300829423 /* FKAccount.m */,
+				5FB8A5B50813FAAB00EDEBC1 /* FKAccount-Accs.m */,
+				5FBA6330091C0AD800CD577F /* FKContact.h */,
+				5FBA6331091C0AD800CD577F /* FKContact.m */,
+			);
+			name = People;
+			sourceTree = "<group>";
+		};
+		5F8DA1860CE4AFD600F7DBC4 /* Account Objects */ = {
+			isa = PBXGroup;
+			children = (
+				5FB24FEF087C167D008B5AB5 /* FKNote.h */,
+				5FB24FF0087C167D008B5AB5 /* FKNote.m */,
+				5F8DA0DA0CE4A36600F7DBC4 /* FKAccountObject.h */,
+				5F8DA0DB0CE4A36600F7DBC4 /* FKAccountObject.m */,
+				5F18B9B70BF1D78F00F552E9 /* FKComment.h */,
+				5F18B9B80BF1D78F00F552E9 /* FKComment.m */,
+				5FD405750CE1E2C2004EABDD /* FKEvent.h */,
+				5FD405760CE1E2C2004EABDD /* FKEvent.m */,
+				5FCC645208142396000FC95A /* FKPhoto.h */,
+				5FCC645308142396000FC95A /* FKPhoto.m */,
+				5FCC66E308150313000FC95A /* FKTag.h */,
+				5FCC66E408150313000FC95A /* FKTag.m */,
+				5F6E3D000818E18100D2D61B /* FKPhotoset.h */,
+				5F1DD00C08168443003D9229 /* FKPhotoset.m */,
+				5F1C3C610C399A9300DF3E71 /* FKPhotoLink.h */,
+				5F1C3C620C399A9300DF3E71 /* FKPhotoLink.m */,
+			);
+			name = "Account Objects";
+			sourceTree = "<group>";
+		};
+		5F8DA1870CE4AFFB00F7DBC4 /* Authentication */ = {
+			isa = PBXGroup;
+			children = (
+				5F0F84260870014500C5DA02 /* FKToken.h */,
+				5F0F84270870014500C5DA02 /* FKToken.m */,
+			);
+			name = Authentication;
+			sourceTree = "<group>";
+		};
+		5F8DA1880CE4B01A00F7DBC4 /* Upload Templates */ = {
+			isa = PBXGroup;
+			children = (
+				5FCC684108153884000FC95A /* FKPhotoUploadRequest.h */,
+				5FCC684208153884000FC95A /* FKPhotoUploadRequest.m */,
+				5FE3542008996F2400636417 /* FKPhotosetCreationEditRequest.h */,
+				5FE3542108996F2400636417 /* FKPhotosetCreationEditRequest.m */,
+			);
+			name = "Upload Templates";
+			sourceTree = "<group>";
+		};
+		5F8DA1890CE4B02700F7DBC4 /* Utilities */ = {
+			isa = PBXGroup;
+			children = (
+				5FFB981609FCC22600F6A041 /* FKSocket */,
+				5FF15ECC088FD91F0055F886 /* FKAPIUtils.h */,
+				5FF15ECD088FD91F0055F886 /* FKAPIUtils.m */,
+				5FF15EDA088FD9570055F886 /* FKCategories.h */,
+				5FF15EDB088FD9570055F886 /* FKCategories.m */,
+				5F0F847A087003A000C5DA02 /* NSData Categories */,
+				5FD9A96E08807A8500E95C71 /* Accessor Categories */,
+				5FDF019F08BA61F8005983AB /* FKSIPSUtilities.h */,
+				5FDF01A008BA61F8005983AB /* FKSIPSUtilities.m */,
+			);
+			name = Utilities;
+			sourceTree = "<group>";
+		};
+		5F8DA18A0CE4B04700F7DBC4 /* MetaCollections */ = {
+			isa = PBXGroup;
+			children = (
+				5F17F316093DABCA0080FFB1 /* FKGroup.h */,
+				5F17F317093DABCA0080FFB1 /* FKGroup.m */,
+				5F667B610B066062007CDAC0 /* FKInterestingness.h */,
+				5F667B620B066062007CDAC0 /* FKInterestingness.m */,
+			);
+			name = MetaCollections;
+			sourceTree = "<group>";
+		};
 		5FB24D4B087A9FA6008B5AB5 /* XML Utils */ = {
 			isa = PBXGroup;
 			children = (
@@ -386,7 +441,6 @@
 		5FD9A96E08807A8500E95C71 /* Accessor Categories */ = {
 			isa = PBXGroup;
 			children = (
-				5FB8A5B50813FAAB00EDEBC1 /* FKAccount-Accs.m */,
 				5FCC64A508144603000FC95A /* FKPhoto-Accs.m */,
 				5FCC66EA08150325000FC95A /* FKTag-Accs.m */,
 				5FCC685108153A5D000FC95A /* FKPhotoUploadRequest-Accs.m */,
@@ -452,6 +506,7 @@
 				5F1C3C630C399A9300DF3E71 /* FKPhotoLink.h in Headers */,
 				5FD405770CE1E2C2004EABDD /* FKEvent.h in Headers */,
 				5FD4057C0CE1E3BF004EABDD /* FKUser.h in Headers */,
+				5F8DA0DC0CE4A36600F7DBC4 /* FKAccountObject.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -594,6 +649,7 @@
 				5F1C3C640C399A9300DF3E71 /* FKPhotoLink.m in Sources */,
 				5FD405780CE1E2C3004EABDD /* FKEvent.m in Sources */,
 				5FD4057D0CE1E3BF004EABDD /* FKUser.m in Sources */,
+				5F8DA0DD0CE4A36600F7DBC4 /* FKAccountObject.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: trunk/Tests/FKAccountTests.m
===================================================================
--- trunk/Tests/FKAccountTests.m	2007-11-09 08:58:37 UTC (rev 418)
+++ trunk/Tests/FKAccountTests.m	2007-11-09 16:51:10 UTC (rev 419)
@@ -63,7 +63,7 @@
 		NSString *targetTitle = [titles objectAtIndex: i];
 		STAssertTrue([actualTitle isEqualToString: targetTitle], @"Photo title incorrect.  Should be \"%@\" and is \"%@\"", targetTitle, actualTitle);
 		
-		int actualPhotoID = [photo photoid];
+		int actualPhotoID = [photo nsid];
 		int targetPhotoID = [ids objectAtIndex: i];
 		STAssertTrue([targetPhotoID isEqualToString: actualPhotoID], @"PhotoID incorrect.  Should be %@ and is %@", targetPhotoID, actualPhotoID);
 		

Modified: trunk/Tests/FKPhotoTests.m
===================================================================
--- trunk/Tests/FKPhotoTests.m	2007-11-09 08:58:37 UTC (rev 418)
+++ trunk/Tests/FKPhotoTests.m	2007-11-09 16:51:10 UTC (rev 419)
@@ -20,7 +20,7 @@
 	[photo processCompleteInformationResult: [xml dataUsingEncoding: NSUTF8StringEncoding]];
 	NSLog(@"Parsed.  %d tags", [[photo tags] count]);
 	
-	STAssertTrue([[photo photoid] isEqualToString: @"2733"], @"Photo ID is not 2733");
+	STAssertTrue([[photo nsid] isEqualToString: @"2733"], @"Photo ID is not 2733");
 	STAssertTrue([[photo secret] isEqualToString: @"123456"], @"Photo secret is not 123456 (was: %@)", [photo secret]);
 	STAssertTrue([photo server] == 12, @"Photo server (%d) is not 12", [photo server]);
 	STAssertTrue([[photo title] isEqualToString: @"orford_castle_taster"], @"Photo title (%@) is not \"orford_castle_taster\"");



More information about the Flickrkit-svn mailing list