diff --git a/Application/AppController.h b/Application/AppController.h index 46ca8cc2d..d6a1fddc3 100644 --- a/Application/AppController.h +++ b/Application/AppController.h @@ -7,7 +7,7 @@ @class PlaybackController; @class PlaylistController; @class PlaylistView; -@class FileTreeController; +@class FileTreeDataSource; @class FileOutlineView; @class AppleRemote; @class PlaylistLoader; @@ -33,7 +33,7 @@ IBOutlet NSDrawer *infoDrawer; IBOutlet NSDrawer *fileDrawer; - IBOutlet FileTreeController *fileTreeController; + IBOutlet FileTreeDataSource *fileTreeDataSource; IBOutlet FileOutlineView *fileOutlineView; IBOutlet PlaylistView *playlistView; diff --git a/Application/AppController.m b/Application/AppController.m index 945ef235d..993c54f8c 100644 --- a/Application/AppController.m +++ b/Application/AppController.m @@ -3,7 +3,6 @@ #import "PlaybackController.h" #import "PlaylistController.h" #import "PlaylistView.h" -#import "FileTreeController.h" #import "FileOutlineView.h" #import "NDHotKeyEvent.h" #import "AppleRemote.h" @@ -400,7 +399,7 @@ increase/decrease as long as the user holds the left/right, plus/minus button */ [self registerHotKeys]; } else if ([keyPath isEqualToString:@"values.fileDrawerRootPath"]) { - [fileTreeController setRootPath:[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"fileDrawerRootPath"]]; + [fileTreeDataSource setRootPath:[[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"fileDrawerRootPath"]]; } else if ([keyPath isEqualToString:@"values.remoteEnabled"] || [keyPath isEqualToString:@"values.remoteOnlyOnActive"]) { if([[NSUserDefaults standardUserDefaults] boolForKey:@"remoteEnabled"]) { diff --git a/Cog.xcodeproj/project.pbxproj b/Cog.xcodeproj/project.pbxproj index 37d65df79..325d1e4fb 100644 --- a/Cog.xcodeproj/project.pbxproj +++ b/Cog.xcodeproj/project.pbxproj @@ -123,7 +123,6 @@ 8EFFCD610AA093AF00C458A5 /* FileIconCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD450AA093AF00C458A5 /* FileIconCell.m */; }; 8EFFCD630AA093AF00C458A5 /* FileNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD470AA093AF00C458A5 /* FileNode.m */; }; 8EFFCD650AA093AF00C458A5 /* FileOutlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD490AA093AF00C458A5 /* FileOutlineView.m */; }; - 8EFFCD690AA093AF00C458A5 /* FileTreeWatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD4D0AA093AF00C458A5 /* FileTreeWatcher.m */; }; 8EFFCD6F0AA093AF00C458A5 /* PathNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD530AA093AF00C458A5 /* PathNode.m */; }; /* End PBXBuildFile section */ @@ -613,10 +612,6 @@ 8EFFCD470AA093AF00C458A5 /* FileNode.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = FileNode.m; sourceTree = ""; }; 8EFFCD480AA093AF00C458A5 /* FileOutlineView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FileOutlineView.h; sourceTree = ""; }; 8EFFCD490AA093AF00C458A5 /* FileOutlineView.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = FileOutlineView.m; sourceTree = ""; }; - 8EFFCD4A0AA093AF00C458A5 /* FileTreeController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FileTreeController.h; sourceTree = ""; }; - 8EFFCD4B0AA093AF00C458A5 /* FileTreeController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = FileTreeController.m; sourceTree = ""; }; - 8EFFCD4C0AA093AF00C458A5 /* FileTreeWatcher.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FileTreeWatcher.h; sourceTree = ""; }; - 8EFFCD4D0AA093AF00C458A5 /* FileTreeWatcher.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = FileTreeWatcher.m; sourceTree = ""; }; 8EFFCD520AA093AF00C458A5 /* PathNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PathNode.h; sourceTree = ""; }; 8EFFCD530AA093AF00C458A5 /* PathNode.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = PathNode.m; sourceTree = ""; }; /* End PBXFileReference section */ @@ -1151,10 +1146,6 @@ 8EFFCD490AA093AF00C458A5 /* FileOutlineView.m */, 1769D7CF0CC2BFF7003F455B /* FileTreeDataSource.h */, 1769D7D00CC2BFF7003F455B /* FileTreeDataSource.m */, - 8EFFCD4A0AA093AF00C458A5 /* FileTreeController.h */, - 8EFFCD4B0AA093AF00C458A5 /* FileTreeController.m */, - 8EFFCD4C0AA093AF00C458A5 /* FileTreeWatcher.h */, - 8EFFCD4D0AA093AF00C458A5 /* FileTreeWatcher.m */, 8EFFCD420AA093AF00C458A5 /* DirectoryNode.h */, 8EFFCD430AA093AF00C458A5 /* DirectoryNode.m */, 8EFFCD460AA093AF00C458A5 /* FileNode.h */, @@ -1507,7 +1498,6 @@ 8EFFCD610AA093AF00C458A5 /* FileIconCell.m in Sources */, 8EFFCD630AA093AF00C458A5 /* FileNode.m in Sources */, 8EFFCD650AA093AF00C458A5 /* FileOutlineView.m in Sources */, - 8EFFCD690AA093AF00C458A5 /* FileTreeWatcher.m in Sources */, 8EFFCD6F0AA093AF00C458A5 /* PathNode.m in Sources */, 8E07AAF30AAC910500A4B32F /* SS_PrefsController.m in Sources */, 8E07AB790AAC930B00A4B32F /* PreferencesController.m in Sources */, diff --git a/English.lproj/MainMenu.nib/classes.nib b/English.lproj/MainMenu.nib/classes.nib index c279543b4..261c25b1d 100644 --- a/English.lproj/MainMenu.nib/classes.nib +++ b/English.lproj/MainMenu.nib/classes.nib @@ -25,11 +25,10 @@ CLASS = AppController; LANGUAGE = ObjC; OUTLETS = { - addURLPanel = NSPanel; fileButton = NSButton; fileDrawer = NSDrawer; fileOutlineView = FileOutlineView; - fileTreeController = FileTreeController; + fileTreeDataSource = FileTreeDataSource; infoButton = NSButton; infoDrawer = NSDrawer; mainWindow = NSPanel; @@ -50,7 +49,6 @@ showTrackColumn = NSMenuItem; showYearColumn = NSMenuItem; shuffleButton = NSButton; - urlComboBox = NSComboBox; }; SUPERCLASS = NSObject; }, @@ -82,10 +80,10 @@ SUPERCLASS = NSOutlineView; }, { - CLASS = FileTreeController; + CLASS = FileTreeDataSource; LANGUAGE = ObjC; - OUTLETS = {playlistLoader = PlaylistLoader; }; - SUPERCLASS = NSTreeController; + OUTLETS = {outlineView = NSOutlineView; }; + SUPERCLASS = NSObject; }, {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, {CLASS = InfoController; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, diff --git a/English.lproj/MainMenu.nib/info.nib b/English.lproj/MainMenu.nib/info.nib index e953b87cb..9fc7298e3 100644 --- a/English.lproj/MainMenu.nib/info.nib +++ b/English.lproj/MainMenu.nib/info.nib @@ -35,8 +35,8 @@ IBOpenObjects 1063 - 268 29 + 268 21 1156 1324 diff --git a/English.lproj/MainMenu.nib/keyedobjects.nib b/English.lproj/MainMenu.nib/keyedobjects.nib index ddaaac14d..3e974c716 100644 Binary files a/English.lproj/MainMenu.nib/keyedobjects.nib and b/English.lproj/MainMenu.nib/keyedobjects.nib differ diff --git a/FileDrawer/DirectoryNode.m b/FileDrawer/DirectoryNode.m index e0827badf..e87c45fda 100644 --- a/FileDrawer/DirectoryNode.m +++ b/FileDrawer/DirectoryNode.m @@ -11,9 +11,6 @@ #import "FileNode.h" #import "SmartFolderNode.h" -#import "FileTreeController.h" -#import "FileTreeWatcher.h" - @implementation DirectoryNode - (BOOL)isLeaf @@ -21,19 +18,11 @@ return NO; } -- (NSArray *)subpaths +- (void)updatePath { - if (subpaths == nil) - { - subpaths = [[NSMutableArray alloc] init]; - NSArray *contents = [[[NSFileManager defaultManager] directoryContentsAtPath:path] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]; - NSLog(@"Contents: %@", contents); - [self processPaths: contents]; - -// [[controller watcher] addPath:[self path]]; - } - - return subpaths; + NSArray *contents = [[[NSFileManager defaultManager] directoryContentsAtPath:path] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]; + + [self processPaths: contents]; } @end diff --git a/FileDrawer/FileIconCell.m b/FileDrawer/FileIconCell.m index d88370c50..9c7935dfd 100644 --- a/FileDrawer/FileIconCell.m +++ b/FileDrawer/FileIconCell.m @@ -7,14 +7,14 @@ // #import "FileIconCell.h" - +#import "PathNode.h" @implementation FileIconCell - (void)setObjectValue:(id)o { - if ([o respondsToSelector:@selector(icon)]) { - [super setObjectValue:[[o path] lastPathComponent]]; + if ([o respondsToSelector:@selector(icon)] && [o respondsToSelector:@selector(displayPath)]) { + [super setObjectValue:[o displayPath]]; [super setImage: [o icon]]; } else { diff --git a/FileDrawer/FileOutlineView.m b/FileDrawer/FileOutlineView.m index 880510d6c..16af03081 100644 --- a/FileDrawer/FileOutlineView.m +++ b/FileDrawer/FileOutlineView.m @@ -31,9 +31,6 @@ [c setDataCell: dataCell]; NSLog(@"Setting data cell!"); } - - dataSource = [[FileTreeDataSource alloc] initWithRoot: [[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"fileDrawerRootPath"] ]; - [self setDataSource: dataSource]; } diff --git a/FileDrawer/FileTreeController.h b/FileDrawer/FileTreeController.h deleted file mode 100644 index 6f6127156..000000000 --- a/FileDrawer/FileTreeController.h +++ /dev/null @@ -1,30 +0,0 @@ -// -// FileTreeController.h -// Cog -// -// Created by Vincent Spader on 8/20/2006. -// Copyright 2006 Vincent Spader. All rights reserved. -// - -#import - -@class FileTreeWatcher; -@class PlaylistLoader; - -@interface FileTreeController : NSTreeController -{ - IBOutlet PlaylistLoader *playlistLoader; - - NSString *rootPath; - - FileTreeWatcher *watcher; -} - -- (FileTreeWatcher *)watcher; - -- (id)rootPath; -- (void)setRootPath:(id)r; -- (void)refreshRoot; -- (NSArray *)acceptableFileTypes; - -@end diff --git a/FileDrawer/FileTreeController.m b/FileDrawer/FileTreeController.m deleted file mode 100644 index 745efa9e2..000000000 --- a/FileDrawer/FileTreeController.m +++ /dev/null @@ -1,208 +0,0 @@ -// -// FileTreeController.m -// Cog -// -// Created by Vincent Spader on 8/20/2006. -// Copyright 2006 Vincent Spader. All rights reserved. -// - -#import "FileTreeController.h" -#import "FileTreeWatcher.h" -#import "DirectoryNode.h" -#import "ImageTextCell.h" -#import "KFTypeSelectTableView.h" -#import "PlaylistLoader.h" - -@implementation FileTreeController - -- (void)awakeFromNib -{ - watcher = [[FileTreeWatcher alloc] init]; - [watcher setDelegate:self]; - - [self setRootPath: [[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"fileDrawerRootPath"] ]; -} - -- (void)dealloc -{ - [rootPath release]; - [watcher release]; - - [super dealloc]; -} - -- (id)rootPath -{ - return rootPath; -} - -- (void)setRootPath:(id)r -{ - [r retain]; - [rootPath release]; - rootPath = r; - - [self refreshRoot]; -} - -- (void) refreshRoot -{ - DirectoryNode *base = [[DirectoryNode alloc] initWithPath:rootPath controller:self]; -// [self setContent: [base subpaths]]; - - [base release]; - - [watcher addPath:rootPath]; -} - -//BUG IN NSTREECONTROLLER'S SETCONTENT. FIX YOUR SHIT, APPLE! -- (void)setContent:(id)content -{ - if(![content isEqual:[self content]]) - { - NSArray *paths = [[self selectionIndexPaths] retain]; - [super setContent:nil]; - [super setContent:content]; - [self setSelectionIndexPaths:paths]; - [paths release]; - } -} - -- (void)refreshPath:(NSString *)path -{ - if ([path compare:rootPath] == NSOrderedSame) { - [self refreshRoot]; - - return; - } - - NSArray *pathComponents = [path pathComponents]; - NSArray *rootComponents = [rootPath pathComponents]; - int i = 0; - while (i < [rootComponents count] && i < [pathComponents count] && - NSOrderedSame == [[rootComponents objectAtIndex: i] compare:[pathComponents objectAtIndex: i]]) - { - i++; - } - - - id p; - NSEnumerator *e = [[self content] objectEnumerator]; - while ((p = [e nextObject])) - { - id c = [pathComponents objectAtIndex:i]; - if (NSOrderedSame == [[[p path] lastPathComponent] compare:c]) { - if (i == [pathComponents count] - 1) { - [p setSubpaths:nil]; -// [self rearrangeObjects]; - } - else { - e = [[c subpaths] objectEnumerator]; - i++; - } - } - } -} - -- (NSArray *)acceptableFileTypes -{ - return [playlistLoader acceptableFileTypes]; -} - -- (FileTreeWatcher *)watcher -{ - return watcher; -} - -- (BOOL)outlineView:(NSOutlineView *)olv writeItems:(NSArray*)items toPasteboard:(NSPasteboard*)pboard { - //Get selected paths - NSMutableArray *paths = [NSMutableArray arrayWithCapacity:[items count]]; - NSEnumerator *e = [items objectEnumerator]; - id p; - - while (p = [e nextObject]) { - int i; - id n = nil; - NSIndexPath *ip = [p indexPath]; - - for (i = 0; i < [ip length]; i++) - { - NSArray *a = (n == nil) ? [self content] : [n subpaths]; - n = [a objectAtIndex:[ip indexAtPosition:i]]; - } - - [paths addObject:[n path]]; - } - - [pboard declareTypes:[NSArray arrayWithObjects:NSFilenamesPboardType,nil] owner:nil]; //add it to pboard - [pboard setPropertyList:paths forType:NSFilenamesPboardType]; - - return YES; -} - - -// Required Protocol Bullshit (RPB) This is neccessary so it can be used as a datasource for drag/drop things. - - - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item - { - return nil; - } - - - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item - { - return NO; - } - - - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item - { - return 0; - } - - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item - { - return nil; - } - -//End of RPB - - -//For type-select - -- (void)configureTypeSelectTableView:(KFTypeSelectTableView *)tableView -{ - [tableView setSearchWraps:YES]; -} - -- (int)typeSelectTableViewInitialSearchRow:(id)tableView -{ - return [tableView selectedRow]; -} - -// Return the string value used for type selection -- (NSString *)typeSelectTableView:(KFTypeSelectTableView *)tableView stringValueForTableColumn:(NSTableColumn *)col row:(int)row -{ - id item = [tableView itemAtRow:row]; - - //Reaching down into NSTreeController...yikes - return [[[item observedObject] path] lastPathComponent]; -} - -//End type-select - -- (void)addSelectedToPlaylist { - NSMutableArray *urls = [[NSMutableArray alloc] init]; - NSArray *nodes = [self selectedObjects]; - NSEnumerator *e = [nodes objectEnumerator]; - - id n; - while (n = [e nextObject]) { - NSURL *url = [[NSURL alloc] initFileURLWithPath:[n path]]; - [urls addObject:url]; - [url release]; - } - - [playlistLoader addURLs:urls sort:YES]; - [urls release]; -} - - -@end diff --git a/FileDrawer/FileTreeWatcher.h b/FileDrawer/FileTreeWatcher.h deleted file mode 100644 index 1b78ffd89..000000000 --- a/FileDrawer/FileTreeWatcher.h +++ /dev/null @@ -1,25 +0,0 @@ -// -// FileTreeDelegate.h -// BindTest -// -// Created by Vincent Spader on 8/20/06. -// Copyright 2006 Vincent Spader. All rights reserved. -// - -#import - -@class UKKQueue; - -@interface FileTreeWatcher : NSObject { - UKKQueue *kqueue; - id delegate; - - NSMutableArray *watchedPaths; -} - -- (void)addPath: (NSString *)path; -- (void)removePath: (NSString *)path; - --(void) setDelegate: (id)d; - -@end diff --git a/FileDrawer/FileTreeWatcher.m b/FileDrawer/FileTreeWatcher.m deleted file mode 100644 index d5d44d95b..000000000 --- a/FileDrawer/FileTreeWatcher.m +++ /dev/null @@ -1,62 +0,0 @@ -// -// FileTreeDelegate.m -// BindTest -// -// Created by Vincent Spader on 8/20/06. -// Copyright 2006 Vincent Spader. All rights reserved. -// - -#import "FileTreeWatcher.h" - -#import "UKKQueue.h" - -@implementation FileTreeWatcher - -- (id)init -{ - self = [super init]; - if (self) - { - kqueue = [[UKKQueue alloc] init]; - [kqueue setDelegate:self]; - - watchedPaths = [[NSMutableArray alloc] init]; - } - - return self; -} - -- (void)dealloc -{ - [delegate release]; - [super dealloc]; -} - - -- (void)addPath: (NSString *)path -{ - if ([watchedPaths containsObject:path] == NO) { - [watchedPaths addObject:path]; - - [kqueue addPath: path]; - } -} - -- (void)removePath: (NSString *)path -{ - [watchedPaths removeObject:path]; - [kqueue removePath:path]; -} - --(void) setDelegate: (id)d -{ - delegate = [d retain]; -} - - --(void) watcher: (id)kq receivedNotification: (NSString*)nm forPath: (NSString*)fpath -{ - [delegate refreshPath: fpath]; -} - -@end diff --git a/FileDrawer/PathNode.h b/FileDrawer/PathNode.h index dc6e1e5c1..05a96f247 100644 --- a/FileDrawer/PathNode.h +++ b/FileDrawer/PathNode.h @@ -8,15 +8,21 @@ #import +@class FileTreeDataSource; + @interface PathNode : NSObject { + FileTreeDataSource *dataSource; + NSString *path; + NSString *displayPath; //The pretty path to display. + NSImage *icon; NSArray *subpaths; } -- (id)initWithPath:(NSString *)p; +- (id)initWithDataSource:(FileTreeDataSource *)ds path:(NSString *)p; - (NSString *)path; - (void)setPath:(NSString *)p; @@ -26,6 +32,7 @@ - (NSArray *)subpaths; - (void)setSubpaths:(NSArray *)s; +- (NSString *)displayPath; - (NSImage *)icon; - (BOOL)isLeaf; diff --git a/FileDrawer/PathNode.m b/FileDrawer/PathNode.m index 6269a69f0..98cfb63bc 100644 --- a/FileDrawer/PathNode.m +++ b/FileDrawer/PathNode.m @@ -10,44 +10,76 @@ #import "CogAudio/AudioPlayer.h" +#import "FileTreeDataSource.h" + +#import "UKKQueue.h" + @class FileNode; @class DirectoryNode; @class SmartFolderNode; @implementation PathNode -- (id)initWithPath:(NSString *)p +- (id)initWithDataSource:(FileTreeDataSource *)ds path:(NSString *)p { self = [super init]; if (self) { + dataSource = ds; [self setPath: p]; } return self; } -- (void)dealloc +- (void)stopWatching { - [path release]; - [icon release]; - - if (subpaths) { - [subpaths release]; - subpaths = nil; - } + if (path) + { + NSLog(@"Stopped watching...: %@", path); - [super dealloc]; + //Remove all in one go + [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self]; + + [[UKKQueue sharedFileWatcher] removePath:path]; + } +} + +- (void)startWatching +{ + if (path) + { + NSLog(@"WATCHING! %@ %i", path, path); + + [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(updatePathNotification:) name:UKFileWatcherRenameNotification object:nil]; + [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(updatePathNotification:) name:UKFileWatcherWriteNotification object:nil]; + [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(updatePathNotification:) name:UKFileWatcherDeleteNotification object:nil]; + [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(updatePathNotification:) name:UKFileWatcherAttributeChangeNotification object:nil]; + [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(updatePathNotification:) name:UKFileWatcherSizeIncreaseNotification object:nil]; + [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(updatePathNotification:) name:UKFileWatcherLinkCountChangeNotification object:nil]; + [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(updatePathNotification:) name:UKFileWatcherAccessRevocationNotification object:nil]; + + [[UKKQueue sharedFileWatcher] addPath:path]; + } } - (void)setPath:(NSString *)p { [p retain]; - [path release]; + [self stopWatching]; + + [path release]; + path = p; + [self startWatching]; + + [displayPath release]; + displayPath = [[NSFileManager defaultManager] displayNameAtPath:path]; + [displayPath retain]; + [icon release]; icon = [[NSWorkspace sharedWorkspace] iconForFile:path]; [icon retain]; @@ -60,6 +92,28 @@ return path; } +- (void)updatePath +{ +} + +- (void)updatePathNotification:(NSNotification *)notification +{ + [self performSelectorOnMainThread:@selector(updatePathNotificationMainThread:) withObject:notification waitUntilDone:YES]; +} + +- (void)updatePathNotificationMainThread:(NSNotification *)notification +{ + NSString *p = [[notification userInfo] objectForKey:@"path"]; + if (p == path) + { + NSLog(@"Update path notification: %@", [NSThread currentThread]); + + [self updatePath]; + + [dataSource reloadPathNode:self]; + } +} + - (void)processPaths: (NSArray *)contents { NSMutableArray *newSubpaths = [[NSMutableArray alloc] init]; @@ -78,7 +132,7 @@ if ([[s pathExtension] caseInsensitiveCompare:@"savedSearch"] == NSOrderedSame) { - newNode = [[SmartFolderNode alloc] initWithPath:newSubpath]; + newNode = [[SmartFolderNode alloc] initWithDataSource:dataSource path:newSubpath]; } else { @@ -92,9 +146,13 @@ } if (isDir) - newNode = [[DirectoryNode alloc] initWithPath: newSubpath]; + { + newNode = [[DirectoryNode alloc] initWithDataSource:dataSource path: newSubpath]; + } else - newNode = [[FileNode alloc] initWithPath: newSubpath]; + { + newNode = [[FileNode alloc] initWithDataSource:dataSource path: newSubpath]; + } } [newSubpaths addObject:newNode]; @@ -102,13 +160,18 @@ [newNode release]; } - [self setSubpaths:[[newSubpaths copy] autorelease]]; + [self setSubpaths:newSubpaths]; [newSubpaths release]; } - (NSArray *)subpaths { + if (subpaths == nil) + { + [self updatePath]; + } + return subpaths; } @@ -125,11 +188,26 @@ return YES; } +- (NSString *)displayPath +{ + return displayPath; +} - (NSImage *)icon { return icon; } +- (void)dealloc +{ + [self stopWatching]; + + [path release]; + [icon release]; + + [subpaths release]; + + [super dealloc]; +} @end diff --git a/FileDrawer/SmartFolderNode.m b/FileDrawer/SmartFolderNode.m index d6c6c1e00..85a0dba71 100644 --- a/FileDrawer/SmartFolderNode.m +++ b/FileDrawer/SmartFolderNode.m @@ -17,26 +17,23 @@ return NO; } -- (NSArray *)subpaths +- (void)updatePath { - if (subpaths == nil) - { - NSDictionary *doc = [NSDictionary dictionaryWithContentsOfFile:path]; - NSString *rawQuery = [doc objectForKey:@"RawQuery"]; - NSArray *searchPaths = [[doc objectForKey:@"SearchCriteria"] objectForKey:@"CurrentFolderPath"]; - - // Ugh, Carbon from now on... - MDQueryRef query = MDQueryCreate(kCFAllocatorDefault, (CFStringRef)rawQuery, NULL, NULL); - - MDQuerySetSearchScope(query, (CFArrayRef)searchPaths, 0); - - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(queryFinished:) name:(NSString*)kMDQueryDidFinishNotification object:(id)query]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(queryUpdate:) name:(NSString*)kMDQueryDidUpdateNotification object:(id)query]; - - MDQueryExecute(query, kMDQueryWantsUpdates); - } + NSDictionary *doc = [NSDictionary dictionaryWithContentsOfFile:path]; + NSString *rawQuery = [doc objectForKey:@"RawQuery"]; + NSArray *searchPaths = [[doc objectForKey:@"SearchCriteria"] objectForKey:@"CurrentFolderPath"]; - return subpaths; + // Ugh, Carbon from now on... + MDQueryRef query = MDQueryCreate(kCFAllocatorDefault, (CFStringRef)rawQuery, NULL, NULL); + + MDQuerySetSearchScope(query, (CFArrayRef)searchPaths, 0); + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(queryFinished:) name:(NSString*)kMDQueryDidFinishNotification object:(id)query]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(queryUpdate:) name:(NSString*)kMDQueryDidUpdateNotification object:(id)query]; + + MDQueryExecute(query, kMDQueryWantsUpdates); + + //Note: This is asynchronous! } - (void)setSubpaths:(id)s diff --git a/Plugins/FileSource/FileSource.m b/Plugins/FileSource/FileSource.m index dc7c45640..aba6bff7f 100644 --- a/Plugins/FileSource/FileSource.m +++ b/Plugins/FileSource/FileSource.m @@ -46,8 +46,11 @@ [_url release]; _url = nil; - fclose(_fd); - _fd = NULL; + if (_fd) + { + fclose(_fd); + _fd = NULL; + } } - (NSURL *)url @@ -74,7 +77,7 @@ } - (void)dealloc { - NSLog(@"DEALLOCATING SOURCE"); + [self close]; [super dealloc]; } diff --git a/Plugins/MAD/MADDecoder.m b/Plugins/MAD/MADDecoder.m index fb7bd8d94..1222f472f 100644 --- a/Plugins/MAD/MADDecoder.m +++ b/Plugins/MAD/MADDecoder.m @@ -566,12 +566,6 @@ static inline signed int scale (mad_fixed_t sample) mad_stream_finish(&_stream); } -- (void)dealloc -{ - NSLog(@"Decoder dealloc"); - [super dealloc]; -} - - (double)seekToTime:(double)milliseconds { unsigned long new_position; diff --git a/TODO b/TODO index 52826501e..9b91915e0 100644 --- a/TODO +++ b/TODO @@ -1 +1,2 @@ -Fix playback and leaks. Playback is very much busted when doing lots of next/forward/moving around. \ No newline at end of file +Ensure file drawer works with metadata search (Smart folders). +Add alias support. \ No newline at end of file diff --git a/ThirdParty/UKKQueue/UKKQueue.m b/ThirdParty/UKKQueue/UKKQueue.m index 3217ef49f..b48286fbd 100644 --- a/ThirdParty/UKKQueue/UKKQueue.m +++ b/ThirdParty/UKKQueue/UKKQueue.m @@ -355,7 +355,8 @@ static UKKQueue * gUKKQueueSharedQueueSingleton = nil; if( ev.fflags ) { NSString* fpath = [[(NSString *)ev.udata retain] autorelease]; // In case one of the notified folks removes the path. - //NSLog(@"UKKQueue: Detected file change: %@", fpath); + + //NSLog(@"UKKQueue: Detected file change: %@ %i", fpath, fpath); [[NSWorkspace sharedWorkspace] noteFileSystemChanged: fpath]; //NSLog(@"ev.flags = %u",ev.fflags); // DEBUG ONLY!