| | 12 | |
|---|
| | 13 | #pragma mark Private Functions |
|---|
| | 14 | |
|---|
| | 15 | - (void)setButton:(NSButton *)button fromKey:(CFStringRef)key forAppID:(CFStringRef)appID withDefault:(BOOL)defaultValue |
|---|
| | 16 | { |
|---|
| | 17 | CFPropertyListRef value; |
|---|
| | 18 | value = CFPreferencesCopyAppValue(key, appID); |
|---|
| | 19 | if(value && CFGetTypeID(value) == CFBooleanGetTypeID()) |
|---|
| | 20 | [button setState:CFBooleanGetValue(value)]; |
|---|
| | 21 | else |
|---|
| | 22 | [button setState:defaultValue]; |
|---|
| | 23 | |
|---|
| | 24 | if(value) |
|---|
| | 25 | CFRelease(value); |
|---|
| | 26 | } |
|---|
| | 27 | |
|---|
| | 28 | - (void)setKey:(CFStringRef)key forAppID:(CFStringRef)appID fromButton:(NSButton *)button |
|---|
| | 29 | { |
|---|
| | 30 | if([button state]) |
|---|
| | 31 | CFPreferencesSetAppValue(key, kCFBooleanTrue, appID); |
|---|
| | 32 | else |
|---|
| | 33 | CFPreferencesSetAppValue(key, kCFBooleanFalse, appID); |
|---|
| | 34 | } |
|---|
| | 35 | |
|---|
| | 36 | - (NSString *)quickTimeComponentDir |
|---|
| | 37 | { |
|---|
| | 38 | NSString *myPath = [[self bundle] bundlePath]; |
|---|
| | 39 | NSString *basePath = nil; |
|---|
| | 40 | |
|---|
| | 41 | if([myPath hasPrefix:NSHomeDirectory()]) |
|---|
| | 42 | basePath = NSHomeDirectory(); |
|---|
| | 43 | else |
|---|
| | 44 | basePath = [NSString stringWithString:@"/"]; |
|---|
| | 45 | |
|---|
| | 46 | return [basePath stringByAppendingPathComponent:@"Library/QuickTime"]; |
|---|
| | 47 | } |
|---|
| | 48 | |
|---|
| | 49 | - (NSString *)coreAudioComponentDir |
|---|
| | 50 | { |
|---|
| | 51 | NSString *myPath = [[self bundle] bundlePath]; |
|---|
| | 52 | NSString *basePath = nil; |
|---|
| | 53 | |
|---|
| | 54 | if([myPath hasPrefix:NSHomeDirectory()]) |
|---|
| | 55 | basePath = NSHomeDirectory(); |
|---|
| | 56 | else |
|---|
| | 57 | basePath = [NSString stringWithString:@"/"]; |
|---|
| | 58 | |
|---|
| | 59 | return [basePath stringByAppendingPathComponent:@"Library/Audio/Plug-Ins/Components"]; |
|---|
| | 60 | } |
|---|
| | 61 | |
|---|
| | 62 | - (InstallStatus)installStatusForComponent:(NSString *)component type:(ComponentType)type withMyVersion:(NSString *)myVersion |
|---|
| | 63 | { |
|---|
| | 64 | NSString *path = nil; |
|---|
| | 65 | |
|---|
| | 66 | switch(type) |
|---|
| | 67 | { |
|---|
| | 68 | case ComponentTypeCoreAudio: |
|---|
| | 69 | path = [self coreAudioComponentDir]; |
|---|
| | 70 | break; |
|---|
| | 71 | case ComponentTypeQuickTime: |
|---|
| | 72 | path = [self quickTimeComponentDir]; |
|---|
| | 73 | break; |
|---|
| | 74 | } |
|---|
| | 75 | path = [path stringByAppendingPathComponent:component]; |
|---|
| | 76 | |
|---|
| | 77 | NSBundle *bundle = [NSBundle bundleWithPath:path]; |
|---|
| | 78 | if(bundle == nil) |
|---|
| | 79 | return InstallStatusNotInstalled; |
|---|
| | 80 | |
|---|
| | 81 | NSString *currentVersion = [[bundle infoDictionary] objectForKey:BundleVersionKey]; |
|---|
| | 82 | if([currentVersion compare:myVersion] == NSOrderedAscending) |
|---|
| | 83 | return InstallStatusOutdated; |
|---|
| | 84 | |
|---|
| | 85 | return InstallStatusInstalled; |
|---|
| | 86 | } |
|---|
| | 87 | |
|---|
| | 88 | #pragma mark Preference Pane Support |
|---|
| 22 | | - (void)setButton:(NSButton *)button fromKey:(CFStringRef)key forAppID:(CFStringRef)appID withDefault:(BOOL)defaultValue |
|---|
| 23 | | { |
|---|
| 24 | | CFPropertyListRef value; |
|---|
| 25 | | value = CFPreferencesCopyAppValue(key, appID); |
|---|
| 26 | | if(value && CFGetTypeID(value) == CFBooleanGetTypeID()) |
|---|
| 27 | | [button setState:CFBooleanGetValue(value)]; |
|---|
| 28 | | else |
|---|
| 29 | | [button setState:defaultValue]; |
|---|
| 30 | | |
|---|
| 31 | | if(value) |
|---|
| 32 | | CFRelease(value); |
|---|
| 33 | | } |
|---|
| 34 | | |
|---|
| 35 | | - (void)setKey:(CFStringRef)key forAppID:(CFStringRef)appID fromButton:(NSButton *)button |
|---|
| 36 | | { |
|---|
| 37 | | if([button state]) |
|---|
| 38 | | CFPreferencesSetAppValue(key, kCFBooleanTrue, appID); |
|---|
| 39 | | else |
|---|
| 40 | | CFPreferencesSetAppValue(key, kCFBooleanFalse, appID); |
|---|
| 41 | | } |
|---|
| 42 | | |
|---|
| | 106 | /* General */ |
|---|
| | 107 | NSDictionary *infoDict = [[self bundle] infoDictionary]; |
|---|
| | 108 | installStatus = [self installStatusForComponent:@"Perian.component" type:ComponentTypeQuickTime withMyVersion:[infoDict objectForKey:BundleVersionKey]]; |
|---|
| | 109 | if(installStatus == InstallStatusNotInstalled) |
|---|
| | 110 | { |
|---|
| | 111 | [textField_installStatus setStringValue:NSLocalizedString(@"Perian is not Installed", @"")]; |
|---|
| | 112 | [button_install setStringValue:NSLocalizedString(@"Install", @"")]; |
|---|
| | 113 | } |
|---|
| | 114 | else if(installStatus == InstallStatusOutdated) |
|---|
| | 115 | { |
|---|
| | 116 | [textField_installStatus setStringValue:NSLocalizedString(@"Perian is Installed, but Outdated", @"")]; |
|---|
| | 117 | [button_install setStringValue:NSLocalizedString(@"Update", @"")]; |
|---|
| | 118 | } |
|---|
| | 119 | else |
|---|
| | 120 | { |
|---|
| | 121 | //Perian is fine, but check components |
|---|
| | 122 | NSDictionary *myComponentsInfo = [infoDict objectForKey:ComponentInfoDictionaryKey]; |
|---|
| | 123 | if(myComponentsInfo != nil) |
|---|
| | 124 | { |
|---|
| | 125 | NSEnumerator *componentEnum = [myComponentsInfo objectEnumerator]; |
|---|
| | 126 | NSDictionary *componentInfo = nil; |
|---|
| | 127 | while((componentInfo = [componentEnum nextObject]) != nil) |
|---|
| | 128 | { |
|---|
| | 129 | InstallStatus tstatus = [self installStatusForComponent:[componentInfo objectForKey:ComponentNameKey] type:[[componentInfo objectForKey:ComponentTypeKey] intValue] withMyVersion:[componentInfo objectForKey:BundleVersionKey]]; |
|---|
| | 130 | if(tstatus < installStatus) |
|---|
| | 131 | installStatus = tstatus; |
|---|
| | 132 | } |
|---|
| | 133 | switch(installStatus) |
|---|
| | 134 | { |
|---|
| | 135 | case InstallStatusNotInstalled: |
|---|
| | 136 | [textField_installStatus setStringValue:NSLocalizedString(@"Perian is Installed, but parts are Not Installed", @"")]; |
|---|
| | 137 | [button_install setStringValue:NSLocalizedString(@"Install", @"")]; |
|---|
| | 138 | break; |
|---|
| | 139 | case InstallStatusOutdated: |
|---|
| | 140 | [textField_installStatus setStringValue:NSLocalizedString(@"Perian is Installed, but parts are Outdated", @"")]; |
|---|
| | 141 | [button_install setStringValue:NSLocalizedString(@"Update", @"")]; |
|---|
| | 142 | break; |
|---|
| | 143 | case InstallStatusInstalled: |
|---|
| | 144 | [textField_installStatus setStringValue:NSLocalizedString(@"Perian is Installed", @"")]; |
|---|
| | 145 | [button_install setStringValue:NSLocalizedString(@"Uninstall", @"")]; |
|---|
| | 146 | break; |
|---|
| | 147 | } |
|---|
| | 148 | } |
|---|
| | 149 | else |
|---|
| | 150 | { |
|---|
| | 151 | [textField_installStatus setStringValue:NSLocalizedString(@"Perian is Installed", @"")]; |
|---|
| | 152 | [button_install setStringValue:NSLocalizedString(@"Uninstall", @"")]; |
|---|
| | 153 | } |
|---|
| | 154 | |
|---|
| | 155 | } |
|---|
| | 156 | |
|---|