Changeset 604

Show
Ignore:
Timestamp:
06/24/07 19:37:34 (1 year ago)
Author:
durin42
Message:

Preliminary version of the component manager. The UI is about as pretty as
roadkill, but it's all bindings so it's easy to make it pretty.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/CPFPerianPrefPaneController.h

    r574 r604  
    66 
    77#define ComponentInfoDictionaryKey      @"Components" 
     8 
    89#define BundleVersionKey @"CFBundleVersion" 
     10#define BundleIdentifierKey @"CFBundleIdentifier" 
     11 
    912#define ComponentNameKey @"Name" 
    1013#define ComponentArchiveNameKey @"ArchiveName" 
     
    97100- (IBAction)saveDynRangeSheet:(id)sender; 
    98101 
     102//Component List 
     103- (NSString *)checkComponentStatusByBundleIdentifier:(NSString *)bundleID; 
     104 
    99105//About 
    100106- (IBAction)launchWebsite:(id)sender; 
  • trunk/CPFPerianPrefPaneController.m

    r574 r604  
    695695} 
    696696 
     697#pragma mark Component Version List 
     698- (NSArray *)installedComponentsForUser:(BOOL)user 
     699{ 
     700        NSString *path = [self basePathForType:ComponentTypeQuickTime user:user]; 
     701        NSArray *installedComponents = [[NSFileManager defaultManager] directoryContentsAtPath:path]; 
     702        NSMutableArray *retArray = [[NSMutableArray alloc] initWithCapacity:[installedComponents count]];  
     703        NSEnumerator *componentEnum = [installedComponents objectEnumerator]; 
     704        NSString *component; 
     705        while ((component = [componentEnum nextObject])) { 
     706                if ([[component pathExtension] isEqualToString:@"component"]) 
     707                        [retArray addObject:component]; 
     708        } 
     709        return [retArray autorelease]; 
     710} 
     711 
     712- (NSDictionary *)componentInfoForComponent:(NSString *)component userInstalled:(BOOL)user 
     713{ 
     714        NSString *compName = component; 
     715        if ([[component pathExtension] isEqualToString:@"component"]) 
     716                compName = [component stringByDeletingPathExtension]; 
     717        NSMutableDictionary *componentInfo = [[NSMutableDictionary alloc] initWithObjectsAndKeys:compName, @"name", NULL]; 
     718        NSBundle *componentBundle = [NSBundle bundleWithPath:[[self basePathForType:ComponentTypeQuickTime  
     719                                                                                                                                                   user:user] stringByAppendingPathComponent:component]]; 
     720        NSDictionary *infoDictionary = nil; 
     721        if (componentBundle) 
     722                infoDictionary = [componentBundle infoDictionary]; 
     723        if (infoDictionary && [infoDictionary objectForKey:BundleIdentifierKey]) { 
     724                NSString *componentVersion = [infoDictionary objectForKey:BundleVersionKey]; 
     725                if (componentVersion) 
     726                        [componentInfo setObject:componentVersion forKey:@"version"]; 
     727                else 
     728                        [componentInfo setObject:@"Unknown" forKey:@"version"]; 
     729                [componentInfo setObject:(user ? @"User" : @"System") forKey:@"installType"]; 
     730                [componentInfo setObject:[self checkComponentStatusByBundleIdentifier:[componentBundle bundleIdentifier]] forKey:@"status"]; 
     731                [componentInfo setObject:[componentBundle bundleIdentifier] forKey:@"bundleID"]; 
     732        } else { 
     733                [componentInfo setObject:@"Unknown" forKey:@"version"]; 
     734                [componentInfo setObject:(user ? @"User" : @"System") forKey:@"installType"]; 
     735                [componentInfo setObject:@"NO BUNDLE" forKey:@"status"]; 
     736                [componentInfo setObject:@"NO BUNDLE" forKey:@"bundleID"]; 
     737        } 
     738        return [componentInfo autorelease]; 
     739} 
     740 
     741- (NSArray *)installedComponents 
     742{ 
     743        NSArray *userComponents = [self installedComponentsForUser:YES]; 
     744        NSArray *systemComponents = [self installedComponentsForUser:NO]; 
     745        unsigned numComponents = [userComponents count] + [systemComponents count]; 
     746        NSMutableArray *components = [[NSMutableArray alloc] initWithCapacity:numComponents]; 
     747        NSEnumerator *compEnum = [userComponents objectEnumerator]; 
     748        NSString *compName; 
     749        while ((compName = [compEnum nextObject])) { 
     750                [components addObject:[self componentInfoForComponent:compName userInstalled:YES]]; 
     751        } 
     752        compEnum = [systemComponents objectEnumerator]; 
     753        while ((compName = [compEnum nextObject])) { 
     754                [components addObject:[self componentInfoForComponent:compName userInstalled:NO]]; 
     755        } 
     756        return [components autorelease]; 
     757} 
     758 
     759- (NSString *)checkComponentStatusByBundleIdentifier:(NSString *)bundleID 
     760{ 
     761        if ([bundleID rangeOfString:@"perian"].location != NSNotFound) 
     762                return @"Internal"; 
     763        return @"External"; 
     764} 
     765 
    697766#pragma mark Check Updates 
    698767- (IBAction)updateCheck:(id)sender  
  • trunk/Perian.xcodeproj/project.pbxproj

    r600 r604  
    11701170                                F5CFD2D60B5012A100616865 /* A52Codec.component */, 
    11711171                                F5CFD2D80B5012A100616865 /* AC3MovieImport.component */, 
    1172                                 F5CFD2DA0B5012A100616865 /* A52Preferences.app */, 
     1172                                F5CFD2DA0B5012A100616865 /* Preferences.app */, 
    11731173                        ); 
    11741174                        name = Products; 
     
    14381438                        sourceTree = BUILT_PRODUCTS_DIR; 
    14391439                }; 
    1440                 F5CFD2DA0B5012A100616865 /* A52Preferences.app */ = { 
     1440                F5CFD2DA0B5012A100616865 /* Preferences.app */ = { 
    14411441                        isa = PBXReferenceProxy; 
    14421442                        fileType = wrapper.application; 
  • trunk/PerianPrefPane.nib/info.nib

    r574 r604  
    44<dict> 
    55        <key>IBDocumentLocation</key> 
    6         <string>137 77 356 240 0 0 1680 1028 </string> 
     6        <string>112 62 356 240 0 0 1440 878 </string> 
    77        <key>IBFramework Version</key> 
    88        <string>446.1</string> 
    99        <key>IBOpenObjects</key> 
    1010        <array> 
    11                 <integer>104</integer> 
    1211                <integer>5</integer> 
    1312        </array> 
    1413        <key>IBSystem Version</key> 
    15         <string>8P135</string> 
     14        <string>8R2218</string> 
    1615</dict> 
    1716</plist>