| | 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 | |
|---|