summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2011-12-18 23:51:13 +0000
committerSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2011-12-18 23:51:13 +0000
commit52dd8ecce8339768bedfb424f9cb233b57cd55f4 (patch)
tree3b2771f36c4fa6a071646da7640370ffcdfe5843
parent04600f548825368b80c710992f1d88be8788591b (diff)
downloadpcsxr-52dd8ecce8339768bedfb424f9cb233b57cd55f4.tar.gz
Changed utisCanHandle to supportedUTIs.
reworked application:openFile: to check if a PcsxrFileHandle supports a file then, if it does, uses the specified PcsxrFileHandle. git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@73485 e17a0e51-4ae3-4d35-97c3-1a29b211df97
-rw-r--r--macosx/ConfigurationController.m4
-rw-r--r--macosx/PcsxrController.m32
-rw-r--r--macosx/PcsxrDiscHandler.m2
-rw-r--r--macosx/PcsxrFileHandle.h2
-rw-r--r--macosx/PcsxrFreezeStateHandler.m2
-rw-r--r--macosx/PcsxrMemCardHandler.m4
-rw-r--r--macosx/PcsxrPluginHandler.m4
7 files changed, 25 insertions, 25 deletions
diff --git a/macosx/ConfigurationController.m b/macosx/ConfigurationController.m
index 71601855..875ced70 100644
--- a/macosx/ConfigurationController.m
+++ b/macosx/ConfigurationController.m
@@ -64,7 +64,7 @@ NSString *memChangeNotifier = @"PcsxrMemoryCardDidChangeNotifier";
[openDlg setCanChooseFiles:YES];
[openDlg setCanChooseDirectories:NO];
- [openDlg setAllowedFileTypes:[PcsxrMemCardHandler utisCanHandle]];
+ [openDlg setAllowedFileTypes:[PcsxrMemCardHandler supportedUTIs]];
path = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:mcd length:strlen(mcd)];
@@ -96,7 +96,7 @@ NSString *memChangeNotifier = @"PcsxrMemoryCardDidChangeNotifier";
[openDlg setDirectoryURL:[NSURL fileURLWithPath:[path stringByDeletingLastPathComponent]]];
[openDlg setNameFieldStringValue:@"New Memory Card File.mcr"];
- [openDlg setAllowedFileTypes:[PcsxrMemCardHandler utisCanHandle]];
+ [openDlg setAllowedFileTypes:[PcsxrMemCardHandler supportedUTIs]];
if ([openDlg runModal] == NSFileHandlingPanelOKButton) {
NSString *mcdPath = [[openDlg URL] path];
diff --git a/macosx/PcsxrController.m b/macosx/PcsxrController.m
index dea933b3..41830c26 100644
--- a/macosx/PcsxrController.m
+++ b/macosx/PcsxrController.m
@@ -55,7 +55,7 @@ static NSString *HandleBinCue(NSString *toHandle)
[openDlg setCanChooseFiles:YES];
[openDlg setCanChooseDirectories:NO];
- [openDlg setAllowedFileTypes:[PcsxrDiscHandler utisCanHandle]];
+ [openDlg setAllowedFileTypes:[PcsxrDiscHandler supportedUTIs]];
if ([openDlg runModal] == NSFileHandlingPanelOKButton) {
NSArray* files = [openDlg URLs];
@@ -135,7 +135,7 @@ static NSString *HandleBinCue(NSString *toHandle)
[openDlg setCanChooseFiles:YES];
[openDlg setCanChooseDirectories:NO];
- [openDlg setAllowedFileTypes:[PcsxrDiscHandler utisCanHandle]];
+ [openDlg setAllowedFileTypes:[PcsxrDiscHandler supportedUTIs]];
if ([openDlg runModal] == NSFileHandlingPanelOKButton) {
NSArray* urls = [openDlg URLs];
@@ -476,22 +476,22 @@ static NSString *HandleBinCue(NSString *toHandle)
NSRunAlertPanel(NSLocalizedString(@"Error opening file",nil), [NSString stringWithFormat:NSLocalizedString(@"Unable to open %@: %@", nil), [filename lastPathComponent], [err localizedFailureReason]], nil, nil, nil);
return NO;
}
- NSObject<PcsxrFileHandle> *hand = nil;
+ NSArray *handlers = [NSArray arrayWithObjects:[PcsxrPluginHandler class], [PcsxrMemCardHandler class], [PcsxrFreezeStateHandler class], [PcsxrDiscHandler class], nil];
BOOL isHandled = NO;
- if(UTTypeEqual(CFSTR("com.codeplex.pcsxr.plugin"), (CFStringRef)utiFile)) {
- hand = [[PcsxrPluginHandler alloc] init];
- isHandled = [hand handleFile:filename];
- } else if(UTTypeEqual(CFSTR("com.codeplex.pcsxr.memcard"), (CFStringRef)utiFile)) {
- hand = [[PcsxrMemCardHandler alloc] init];
- isHandled = [hand handleFile:filename];
- } else if(UTTypeEqual(CFSTR("com.codeplex.pcsxr.freeze"), (CFStringRef)utiFile)) {
- hand = [[PcsxrFreezeStateHandler alloc] init];
- isHandled = [hand handleFile:filename];
- } else if(UTTypeEqual(CFSTR("com.alcohol-soft.mdfdisc"), (CFStringRef)utiFile) || UTTypeEqual(CFSTR("com.apple.disk-image-ndif"), (CFStringRef)utiFile) || UTTypeEqual(CFSTR("public.iso-image"), (CFStringRef)utiFile) || UTTypeEqual(CFSTR("com.codeplex.pcsxr.cuefile"), (CFStringRef)utiFile)) {
- hand = [[PcsxrDiscHandler alloc] init];
- isHandled = [hand handleFile:HandleBinCue(filename)];
+ for (Class fileHandler in handlers) {
+ NSObject<PcsxrFileHandle> *hand = [[fileHandler alloc] init];
+ BOOL canHandle = NO;
+ for (NSString *uti in [fileHandler supportedUTIs]) {
+ if ([[NSWorkspace sharedWorkspace] type:utiFile conformsToType:uti]) {
+ canHandle = YES;
+ }
+ }
+ if (canHandle) {
+ isHandled = [hand handleFile:HandleBinCue(filename)];
+ }
+ [hand release];
+
}
- if (hand) [hand release];
return isHandled;
}
diff --git a/macosx/PcsxrDiscHandler.m b/macosx/PcsxrDiscHandler.m
index 9ba27a79..891acc6c 100644
--- a/macosx/PcsxrDiscHandler.m
+++ b/macosx/PcsxrDiscHandler.m
@@ -13,7 +13,7 @@
@implementation PcsxrDiscHandler
-+ (NSArray *)utisCanHandle
++ (NSArray *)supportedUTIs
{
return [NSArray arrayWithObjects:@"com.alcohol-soft.mdfdisc", @"com.codeplex.pcsxr.cuefile", @"com.apple.disk-image-ndif", @"public.iso-image", nil];
}
diff --git a/macosx/PcsxrFileHandle.h b/macosx/PcsxrFileHandle.h
index 199e8bef..f3467a67 100644
--- a/macosx/PcsxrFileHandle.h
+++ b/macosx/PcsxrFileHandle.h
@@ -10,7 +10,7 @@
@protocol PcsxrFileHandle <NSObject>
-+ (NSArray *)utisCanHandle;
++ (NSArray *)supportedUTIs;
- (BOOL)handleFile:(NSString *)theFile;
@end
diff --git a/macosx/PcsxrFreezeStateHandler.m b/macosx/PcsxrFreezeStateHandler.m
index 5e1e493c..934aff19 100644
--- a/macosx/PcsxrFreezeStateHandler.m
+++ b/macosx/PcsxrFreezeStateHandler.m
@@ -12,7 +12,7 @@
@implementation PcsxrFreezeStateHandler
-+ (NSArray *)utisCanHandle
++ (NSArray *)supportedUTIs
{
return [NSArray arrayWithObject:@"com.codeplex.pcsxr.freeze"];
}
diff --git a/macosx/PcsxrMemCardHandler.m b/macosx/PcsxrMemCardHandler.m
index 7998cdda..b8d3cdd9 100644
--- a/macosx/PcsxrMemCardHandler.m
+++ b/macosx/PcsxrMemCardHandler.m
@@ -11,7 +11,7 @@
@implementation PcsxrMemCardHandler
-+ (NSArray *)utisCanHandle
++ (NSArray *)supportedUTIs
{
return [NSArray arrayWithObject:@"com.codeplex.pcsxr.memcard"];
}
@@ -28,7 +28,7 @@
- (id)init
{
- self = [super initWithWindowNibName:@"PcsxrMemCardDocument"];
+ self = [self initWithWindowNibName:@"PcsxrMemCardDocument"];
return self;
}
diff --git a/macosx/PcsxrPluginHandler.m b/macosx/PcsxrPluginHandler.m
index 48f758af..395c2461 100644
--- a/macosx/PcsxrPluginHandler.m
+++ b/macosx/PcsxrPluginHandler.m
@@ -10,7 +10,7 @@
@implementation PcsxrPluginHandler
-+ (NSArray *)utisCanHandle
++ (NSArray *)supportedUTIs
{
return [NSArray arrayWithObject:@"com.codeplex.pcsxr.plugin"];
}
@@ -27,7 +27,7 @@
- (id)init
{
- self = [super initWithWindowNibName:@"AddPluginSheet"];
+ self = [self initWithWindowNibName:@"AddPluginSheet"];
return self;
}