From 96ed93e5eb0b111bd81bebb7b66842e063288129 Mon Sep 17 00:00:00 2001 From: vspader Date: Sun, 10 Jun 2007 22:05:49 +0000 Subject: [PATCH] Fixed some problems with non-lowercase file extensions. Added automatic filetype finding for quicktime plugin. Note that the files it adds are rather generous (txt, swf, and other file types that are not neccessarily audio) --- Audio/AudioDecoder.m | 2 +- Audio/AudioMetadataReader.m | 2 +- Audio/AudioPropertiesReader.m | 2 +- Audio/PluginController.m | 6 +-- .../Quicktime.xcodeproj/project.pbxproj | 4 ++ Plugins/Quicktime/QuicktimeDecoder.m | 41 ++++++++++++++++++- 6 files changed, 49 insertions(+), 8 deletions(-) diff --git a/Audio/AudioDecoder.m b/Audio/AudioDecoder.m index 5b106eb1b..70521e8c6 100644 --- a/Audio/AudioDecoder.m +++ b/Audio/AudioDecoder.m @@ -18,7 +18,7 @@ NSDictionary *decoders = [[PluginController sharedPluginController] decoders]; - Class decoder = NSClassFromString([decoders objectForKey:ext]); + Class decoder = NSClassFromString([decoders objectForKey:[ext lowercaseString]]); return [[[decoder alloc] init] autorelease]; } diff --git a/Audio/AudioMetadataReader.m b/Audio/AudioMetadataReader.m index 993bd15a0..c99631e1d 100644 --- a/Audio/AudioMetadataReader.m +++ b/Audio/AudioMetadataReader.m @@ -17,7 +17,7 @@ NSDictionary *metadataReaders = [[PluginController sharedPluginController] metadataReaders]; - Class metadataReader = NSClassFromString([metadataReaders objectForKey:ext]); + Class metadataReader = NSClassFromString([metadataReaders objectForKey:[ext lowercaseString]]); return [[[[metadataReader alloc] init] autorelease] metadataForURL:url]; diff --git a/Audio/AudioPropertiesReader.m b/Audio/AudioPropertiesReader.m index 604815fb9..506f19593 100644 --- a/Audio/AudioPropertiesReader.m +++ b/Audio/AudioPropertiesReader.m @@ -23,7 +23,7 @@ NSDictionary *propertiesReaders = [[PluginController sharedPluginController] propertiesReaders]; - Class propertiesReader = NSClassFromString([propertiesReaders objectForKey:ext]); + Class propertiesReader = NSClassFromString([propertiesReaders objectForKey:[ext lowercaseString]]); NSDictionary *properties = [propertiesReader propertiesForSource:source]; diff --git a/Audio/PluginController.m b/Audio/PluginController.m index 0ff34f86a..3b08fb677 100644 --- a/Audio/PluginController.m +++ b/Audio/PluginController.m @@ -148,7 +148,7 @@ static PluginController *sharedPluginController = nil; id fileType; while (fileType = [fileTypesEnum nextObject]) { - [decoders setObject:className forKey:fileType]; + [decoders setObject:className forKey:[fileType lowercaseString]]; } } } @@ -161,7 +161,7 @@ static PluginController *sharedPluginController = nil; id fileType; while (fileType = [fileTypesEnum nextObject]) { - [metadataReaders setObject:className forKey:fileType]; + [metadataReaders setObject:className forKey:[fileType lowercaseString]]; } } } @@ -174,7 +174,7 @@ static PluginController *sharedPluginController = nil; id fileType; while (fileType = [fileTypesEnum nextObject]) { - [propertiesReaders setObject:className forKey:fileType]; + [propertiesReaders setObject:className forKey:[fileType lowercaseString]]; } } } diff --git a/Plugins/Quicktime/Quicktime.xcodeproj/project.pbxproj b/Plugins/Quicktime/Quicktime.xcodeproj/project.pbxproj index 076ba0be2..8bfc27e71 100644 --- a/Plugins/Quicktime/Quicktime.xcodeproj/project.pbxproj +++ b/Plugins/Quicktime/Quicktime.xcodeproj/project.pbxproj @@ -12,6 +12,7 @@ 1727BFE60C1C956F0084363D /* QuicktimePropertiesReader.m in Sources */ = {isa = PBXBuildFile; fileRef = 1727BFE50C1C956F0084363D /* QuicktimePropertiesReader.m */; }; 1727C0670C1C97A00084363D /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1727C0660C1C97A00084363D /* AudioToolbox.framework */; }; 1727C0BE0C1C9E180084363D /* QuickTime.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1727C0BD0C1C9E180084363D /* QuickTime.framework */; }; + 1727C2E50C1CA97C0084363D /* QTKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1727C2E40C1CA97C0084363D /* QTKit.framework */; }; 8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; /* End PBXBuildFile section */ @@ -28,6 +29,7 @@ 1727BFE50C1C956F0084363D /* QuicktimePropertiesReader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QuicktimePropertiesReader.m; sourceTree = ""; }; 1727C0660C1C97A00084363D /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = /System/Library/Frameworks/AudioToolbox.framework; sourceTree = ""; }; 1727C0BD0C1C9E180084363D /* QuickTime.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickTime.framework; path = /System/Library/Frameworks/QuickTime.framework; sourceTree = ""; }; + 1727C2E40C1CA97C0084363D /* QTKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QTKit.framework; path = /System/Library/Frameworks/QTKit.framework; sourceTree = ""; }; 32DBCF630370AF2F00C91783 /* Quicktime_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Quicktime_Prefix.pch; sourceTree = ""; }; 8D5B49B6048680CD000E48DA /* Quicktime.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Quicktime.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = Info.plist; sourceTree = ""; }; @@ -42,6 +44,7 @@ 8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */, 1727C0670C1C97A00084363D /* AudioToolbox.framework in Frameworks */, 1727C0BE0C1C9E180084363D /* QuickTime.framework in Frameworks */, + 1727C2E50C1CA97C0084363D /* QTKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -94,6 +97,7 @@ 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = { isa = PBXGroup; children = ( + 1727C2E40C1CA97C0084363D /* QTKit.framework */, 1727C0BD0C1C9E180084363D /* QuickTime.framework */, 1727C0660C1C97A00084363D /* AudioToolbox.framework */, 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */, diff --git a/Plugins/Quicktime/QuicktimeDecoder.m b/Plugins/Quicktime/QuicktimeDecoder.m index cc375c678..1ec3b4415 100644 --- a/Plugins/Quicktime/QuicktimeDecoder.m +++ b/Plugins/Quicktime/QuicktimeDecoder.m @@ -7,7 +7,7 @@ // #import "QuicktimeDecoder.h" - +#import "Quicktime/QuicktimeComponents.h" @implementation QuicktimeDecoder @@ -160,7 +160,44 @@ + (NSArray *)fileTypes { - return [NSArray arrayWithObjects:@"m4a",nil]; + NSMutableArray *extensions = [NSMutableArray array]; + + Component component = NULL; + ComponentDescription looking; + NSCharacterSet *spaceSet = [NSCharacterSet characterSetWithCharactersInString:@" '"]; + + looking.componentType = MovieImportType; + looking.componentSubType = 0; // Any subtype is OK + looking.componentManufacturer = 0; // Any manufacturer is OK + looking.componentFlags = movieImportSubTypeIsFileExtension; + looking.componentFlagsMask = movieImportSubTypeIsFileExtension; + + while (component = FindNextComponent(component, &looking)) { + ComponentDescription description; + + if (GetComponentInfo(component, &description, NULL, NULL, NULL) == noErr) { + + NSString *HFSType = NSFileTypeForHFSTypeCode(description.componentSubType); + + NSLog(@"Extension?: %@", HFSType); + [extensions addObject:[HFSType stringByTrimmingCharactersInSet:spaceSet]]; + + // the extension is present in the description.componentSubType field, which really holds + // a 32-bit number. you need to convert that to a string, and trim off any trailing spaces. + // here's a quickie... + char ext[5] = {0}; + NSString *extension; + + bcopy(&description.componentSubType, ext, 4); + + extension = [[NSString stringWithCString:ext] stringByTrimmingCharactersInSet:spaceSet]; + + // do something with extension here ... + [extensions addObject:extension]; + } + } + + return extensions; } - (NSDictionary *)properties