Permalink
Browse files

IMBObject.location is always a URL.

  • Loading branch information...
1 parent 4954ca3 commit 985b8fa5eaf268abbcfafaf0c89989fff7adec08 @mikeabdullah committed Apr 28, 2012
Showing with 18 additions and 64 deletions.
  1. +1 −1 IMBApertureParser.m
  2. +1 −1 IMBAppleMediaParser.m
  3. +2 −2 IMBFolderParser.m
  4. +1 −1 IMBLightroomParser.m
  5. +3 −3 IMBObject.h
  6. +3 −35 IMBObject.m
  7. +1 −15 IMBParser.m
  8. +1 −1 IMBPyramidObjectPromise.m
  9. +1 −1 IMBSafariParser.m
  10. +3 −3 IMBiPhotoParser.m
  11. +1 −1 IMBiTunesAudioParser.m
View
@@ -694,7 +694,7 @@ - (void) populateNode:(IMBNode*)inNode albums:(NSArray*)inAlbums images:(NSDicti
[objects addObject:object];
[object release];
- object.location = (id)[NSURL fileURLWithPath:path isDirectory:NO];
+ object.location = [NSURL fileURLWithPath:path isDirectory:NO];
object.name = caption;
object.preliminaryMetadata = preliminaryMetadata; // This metadata from the XML file is available immediately
object.metadata = nil; // Build lazily when needed (takes longer)
@@ -828,7 +828,7 @@ - (void) populateFacesNode:(IMBNode*)inNode
path = [keyPhotoDict objectForKey:@"ImagePath"];
object.representedNodeIdentifier = subnode.identifier;
- object.location = (id)[NSURL fileURLWithPath:path isDirectory:NO];
+ object.location = [NSURL fileURLWithPath:path isDirectory:NO];
object.name = subnode.name;
object.parserIdentifier = [self identifier];
object.index = index++;
View
@@ -273,7 +273,7 @@ - (BOOL) populateNode:(IMBNode*)inNode error:(NSError**)outError
IMBFolderObject* object = [[IMBFolderObject alloc] init];
object.representedNodeIdentifier = subnode.identifier;
- object.location = (id)url;
+ object.location = url;
object.name = name;
object.metadata = nil;
object.parserIdentifier = self.identifier;
@@ -316,7 +316,7 @@ - (NSData*) bookmarkForObject:(IMBObject*)inObject error:(NSError**)outError
- (IMBObject*) objectForURL:(NSString*)inURL name:(NSString*)inName index:(NSUInteger)inIndex;
{
IMBObject* object = [[[IMBObject alloc] init] autorelease];
- object.location = (id)inURL;
+ object.location = inURL;
object.name = inName;
object.parserIdentifier = self.identifier;
object.index = inIndex;
@@ -469,7 +469,7 @@ - (NSData*) bookmarkForObject:(IMBObject*)inObject error:(NSError**)outError
if (jpegData != nil) {
IMBLightroomObject* lightroomObject = (IMBLightroomObject*)inObject;
NSString* orientation = [[lightroomObject preliminaryMetadata] objectForKey:@"orientation"];;
- NSString* fileName = [[(NSURL*)inObject.location lastPathComponent] stringByDeletingPathExtension];
+ NSString* fileName = [[inObject.location lastPathComponent] stringByDeletingPathExtension];
NSString* jpegPath = [[[NSFileManager imb_threadSafeManager] imb_uniqueTemporaryFile:fileName] stringByAppendingPathExtension:@"jpg"];
NSURL* jpegURL = [NSURL fileURLWithPath:jpegPath];
BOOL success = NO;
View
@@ -76,11 +76,11 @@ extern NSString* kIMBObjectPasteboardType;
// IMBObject encapsulates information about a single media item (e.g. image file or audio file). The location
-// property uniquely identifies the item. In the case of files it could be a path or NSURL...
+// property uniquely identifies the item.
@interface IMBObject : NSObject <NSCopying,NSCoding,IMBImageItem,QLPreviewItem,NSPasteboardItemDataProvider>
{
- id _location;
+ NSURL *_location;
NSData* _bookmark;
NSString* _name;
NSString* _identifier;
@@ -105,7 +105,7 @@ extern NSString* kIMBObjectPasteboardType;
NSUInteger _imageVersion;
}
-@property (retain) id location; // Path, URL, or other location info
+@property (copy) NSURL *location;
@property (retain) NSString* name; // Display name for user interface
@property (readonly) NSImage* icon; // Small icon to be displayed in list view
@property (retain) NSString* identifier; // Unique identifier for this object
View
@@ -324,37 +324,15 @@ - (id) copyWithZone:(NSZone*)inZone
- (NSString*) path
{
- NSString* path = nil;
-
- if ([_location isKindOfClass:[NSURL class]])
- {
- path = [(NSURL*)_location path];
- }
- else if ([_location isKindOfClass:[NSString class]])
- {
- path = (NSString*)_location;
- }
-
- return path;
+ return [_location path];
}
// Convert location to url...
- (NSURL*) URL
{
- NSURL* url = nil;
-
- if ([_location isKindOfClass:[NSURL class]])
- {
- url = (NSURL*)_location;
- }
- else if ([_location isKindOfClass:[NSString class]])
- {
- url = [NSURL fileURLWithPath:(NSString*)_location];
- }
-
- return url;
+ return _location;
}
@@ -363,17 +341,7 @@ - (NSURL*) URL
- (BOOL) isLocalFile
{
- if ([_location isKindOfClass:[NSURL class]])
- {
- return [(NSURL*)_location isFileURL];
- }
- else if ([_location isKindOfClass:[NSString class]])
- {
- NSString* path = (NSString*)_location;
- return [[NSFileManager imb_threadSafeManager] fileExistsAtPath:path];
- }
-
- return NO;
+ return [(NSURL*)_location isFileURL];
}
View
@@ -289,22 +289,8 @@ - (NSString*) identifierForPath:(NSString*)inPath
- (NSString*) identifierForObject:(IMBObject*)inObject
{
NSString* prefix = [self identifierPrefix];
- NSString* location = nil;
- if ([inObject.location isKindOfClass:[NSString class]])
- {
- location = (NSString*)inObject.location;
- }
- else if ([inObject.location isKindOfClass:[NSURL class]])
- {
- location = [(NSURL*)inObject.location path];
- }
- else
- {
- location = [inObject.location description];
- }
-
- return [NSString stringWithFormat:@"%@:/%@",prefix,location];
+ return [NSString stringWithFormat:@"%@:/%@",prefix,inObject.location];
}
@@ -140,7 +140,7 @@ + (NSURL*)urlForObject:(IMBLightroomObject*)lightroomObject
if (index != NSNotFound) {
BOOL success = NO;
NSData* jpegData = [data subdataWithRange:NSMakeRange(index, [data length] - index)];
- NSString* fileName = [[(NSString*)lightroomObject.location lastPathComponent] stringByDeletingPathExtension];
+ NSString* fileName = [[lightroomObject.location lastPathComponent] stringByDeletingPathExtension];
NSString* jpegPath = [[[NSFileManager imb_threadSafeManager] imb_uniqueTemporaryFile:fileName] stringByAppendingPathExtension:@"jpg"];
if ((orientation == nil) || [orientation isEqual:@"AB"]) {
View
@@ -376,7 +376,7 @@ - (IMBObject*) objectForPlist:(NSDictionary*)inPlist
if (url)
{
- object.location = (id)url;
+ object.location = url;
object.imageRepresentationType = IKImageBrowserNSURLRepresentationType;
}
else
View
@@ -641,7 +641,7 @@ - (void) populateEventsNode:(IMBNode*)inNode withEvents:(NSArray*)inEvents image
path = [keyPhotoDict objectForKey:@"ImagePath"];
object.representedNodeIdentifier = subnode.identifier;
- object.location = (id)[NSURL fileURLWithPath:path isDirectory:NO];
+ object.location = [NSURL fileURLWithPath:path isDirectory:NO];
object.name = subnode.name;
object.parserIdentifier = [self identifier];
object.index = index++;
@@ -694,7 +694,7 @@ - (void) populateAlbumNode:(IMBNode*)inNode images:(NSDictionary*)inImages
[objects addObject:object];
[object release];
- object.location = (id)[NSURL fileURLWithPath:path isDirectory:NO];
+ object.location = [NSURL fileURLWithPath:path isDirectory:NO];
object.name = name;
object.preliminaryMetadata = imageDict; // This metadata from the XML file is available immediately
object.metadata = nil; // Build lazily when needed (takes longer)
@@ -794,7 +794,7 @@ - (void) populatePhotoStreamNode:(IMBNode*)inNode images:(NSDictionary*)inImages
[objects addObject:object];
[object release];
- object.location = (id)[NSURL fileURLWithPath:path isDirectory:NO];
+ object.location = [NSURL fileURLWithPath:path isDirectory:NO];
object.name = name;
object.preliminaryMetadata = imageDict; // This metadata from the XML file is available immediately
object.metadata = nil; // Build lazily when needed (takes longer)
@@ -555,7 +555,7 @@ - (void) populateNode:(IMBNode*)inNode playlists:(NSArray*)inPlaylists tracks:(N
// For local files path is preferred (as we gain automatic support for some context menu items).
// For remote files we'll use a URL (less context menu support)...
- object.location = (id)url;
+ object.location = url;
object.name = name;
object.parserIdentifier = self.identifier;
object.index = index++;

0 comments on commit 985b8fa

Please sign in to comment.