Permalink
Browse files

* NSBundles cache, so don't use them anymore.

 * Added Framework Type


git-svn-id: https://svn.perian.org/trunk@247 621663c8-3916-0410-8f58-edc14a8543d5
  • Loading branch information...
gbooker
gbooker committed Jan 6, 2007
1 parent ae93b71 commit 898af8970e3c06993925dcfcd31279e3f7e4524b
Showing with 38 additions and 12 deletions.
  1. +8 −1 CPFPerianPrefPaneController.h
  2. +30 −11 CPFPerianPrefPaneController.m
@@ -3,6 +3,12 @@
#import <Cocoa/Cocoa.h>
#import <PreferencePanes/NSPreferencePane.h>
#define ComponentInfoDictionaryKey @"Components"
#define BundleVersionKey @"CFBundleVersion"
#define ComponentNameKey @"Name"
#define ComponentArchiveNameKey @"ArchiveName"
#define ComponentTypeKey @"Type"
typedef enum
{
InstallStatusNotInstalled,
@@ -13,7 +19,8 @@ typedef enum
typedef enum
{
ComponentTypeQuickTime,
ComponentTypeCoreAudio
ComponentTypeCoreAudio,
ComponentTypeFramework
} ComponentType;
@interface CPFPerianPrefPaneController : NSPreferencePane
@@ -2,12 +2,6 @@
#import <Security/Security.h>
#include <sys/stat.h>
#define ComponentInfoDictionaryKey @"Components"
#define BundleVersionKey @"CFBundleVersion"
#define ComponentNameKey @"Name"
#define ComponentArchiveNameKey @"ArchiveName"
#define ComponentTypeKey @"Type"
#define AC3DynamicRangeKey CFSTR("dynamicRange")
#define AC3StereoOverDolbyKey CFSTR("useStereoOverDolby")
@@ -69,6 +63,18 @@ - (NSString *)coreAudioComponentDir
return [basePath stringByAppendingPathComponent:@"Library/Audio/Plug-Ins/Components"];
}
- (NSString *)frameworkComponentDir
{
NSString *basePath = nil;
if(![self systemInstalled])
basePath = NSHomeDirectory();
else
basePath = [NSString stringWithString:@"/"];
return [basePath stringByAppendingPathComponent:@"Library/Frameworks"];
}
- (InstallStatus)installStatusForComponent:(NSString *)component type:(ComponentType)type withMyVersion:(NSString *)myVersion
{
NSString *path = nil;
@@ -81,14 +87,17 @@ - (InstallStatus)installStatusForComponent:(NSString *)component type:(Component
case ComponentTypeQuickTime:
path = [self quickTimeComponentDir];
break;
case ComponentTypeFramework:
path = [self frameworkComponentDir];
break;
}
path = [path stringByAppendingPathComponent:component];
NSBundle *bundle = [NSBundle bundleWithPath:path];
if(bundle == nil)
NSDictionary *infoDict = [NSDictionary dictionaryWithContentsOfFile:[path stringByAppendingPathComponent:@"Contents/Info.plist"]];
if(infoDict == nil)
return InstallStatusNotInstalled;
NSString *currentVersion = [[bundle infoDictionary] objectForKey:BundleVersionKey];
NSString *currentVersion = [infoDict objectForKey:BundleVersionKey];
if([currentVersion compare:myVersion] == NSOrderedAscending)
return InstallStatusOutdated;
@@ -161,7 +170,7 @@ - (void)checkForInstallation
[button_install setTitle:NSLocalizedString(@"Uninstall Perian", @"")];
}
}
}
}
- (void)mainViewDidLoad
@@ -303,6 +312,9 @@ - (BOOL)installArchive:(NSString *)archivePath forPiece:(NSString *)component ty
case ComponentTypeQuickTime:
containingDir = [self quickTimeComponentDir];
break;
case ComponentTypeFramework:
containingDir = [self frameworkComponentDir];
break;
}
InstallStatus pieceStatus = [self installStatusForComponent:component type:type withMyVersion:myVersion];
if(auth != nil && pieceStatus != InstallStatusInstalled)
@@ -341,6 +353,7 @@ - (void)install:(id)sender
NSString *componentPath = [[[self bundle] resourcePath] stringByAppendingPathComponent:@"Components"];
NSString *coreAudioComponentPath = [componentPath stringByAppendingPathComponent:@"CoreAudio"];
NSString *quickTimeComponentPath = [componentPath stringByAppendingPathComponent:@"QuickTime"];
NSString *frameworkComponentPath = [componentPath stringByAppendingPathComponent:@"Frameworks"];
AuthorizationRef auth = nil;
if([self systemInstalled])
@@ -366,6 +379,9 @@ - (void)install:(id)sender
case ComponentTypeQuickTime:
archivePath = [quickTimeComponentPath stringByAppendingPathComponent:[myComponent objectForKey:ComponentArchiveNameKey]];
break;
case ComponentTypeFramework:
archivePath = [frameworkComponentPath stringByAppendingPathComponent:[myComponent objectForKey:ComponentArchiveNameKey]];
break;
}
[self installArchive:archivePath forPiece:[myComponent objectForKey:ComponentNameKey] type:type withMyVersion:[myComponent objectForKey:BundleVersionKey] andAuthorization:auth];
}
@@ -406,8 +422,11 @@ - (void)uninstall:(id)sender
case ComponentTypeQuickTime:
directory = [self quickTimeComponentDir];
break;
case ComponentTypeFramework:
directory = [self frameworkComponentDir];
break;
}
BOOL result = [[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:directory destination:@"" files:[myComponent objectForKey:ComponentNameKey] tag:&tag];
result = [[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:directory destination:@"" files:[myComponent objectForKey:ComponentNameKey] tag:&tag];
}
if(auth != nil)
AuthorizationFree(auth, 0);

0 comments on commit 898af89

Please sign in to comment.