diff --git a/Framework/src/MZDataProviderPlugin.m b/Framework/src/MZDataProviderPlugin.m index 219f72f8..6cf24a5d 100644 --- a/Framework/src/MZDataProviderPlugin.m +++ b/Framework/src/MZDataProviderPlugin.m @@ -14,7 +14,6 @@ - (BOOL)isEnabled return YES; } - - (NSArray *)types { NSArray* types = [self.bundle objectForInfoDictionaryKey:@"CFBundleDocumentTypes"]; diff --git a/Framework/src/MZPluginController.m b/Framework/src/MZPluginController.m index b47e8b21..ecc8e21c 100644 --- a/Framework/src/MZPluginController.m +++ b/Framework/src/MZPluginController.m @@ -49,6 +49,20 @@ - (id)initWithController:(MZPluginController *)controller @end +@interface MZNoPluginNotification : MZReadNotification +{ + NSString* fileName; +} + ++ (id)notifierWithController:(MZPluginController *)controller + delegate:(id)delegate + fromFile:(NSString *)fileName; +- (id)initWithController:(MZPluginController *)controller + delegate:(id)delegate + fromFile:(NSString *)fileName; + +@end + @interface MZSearchDelegate : NSObject { @@ -709,8 +723,12 @@ - (MZSearchProviderPlugin *)searchProviderWithIdentifier:(NSString *)identifier { MZDataProviderPlugin* provider = [self dataProviderForPath:fileName]; if(!provider) { + id otherDelegate = + [MZNoPluginNotification notifierWithController:self + delegate:theDelegate + fromFile:fileName]; MZLoggerInfo(@"No plugin for file '%@'", fileName); - return nil; + return otherDelegate; } id otherDelegate = [MZReadNotification notifierWithController:self delegate:theDelegate]; @@ -897,6 +915,57 @@ - (void)dataProvider:(MZDataProviderPlugin *)provider @end +@implementation MZNoPluginNotification + ++ (id)notifierWithController:(MZPluginController *)controller + delegate:(id)delegate + fromFile:(NSString *)fileName +{ + return [[[self alloc] initWithController:controller delegate:delegate fromFile:fileName] autorelease]; +} + +- (id)initWithController:(MZPluginController *)theController + delegate:(id)theDelegate + fromFile:(NSString *)theFileName +{ + self = [super initWithController:theController + delegate:theDelegate]; + if(self) + { + fileName = [theFileName retain]; + [self performSelectorOnMainThread:@selector(noPlugin) withObject:nil waitUntilDone:NO]; + } + return self; +} + +- (void)dealloc +{ + [fileName release]; + [super dealloc]; +} + +- (void)noPlugin +{ + NSDictionary* dict = [NSDictionary dictionaryWithObject: + NSLocalizedString(@"No plugin found for file", @"No read plugin error") + forKey:NSLocalizedDescriptionKey]; + NSError* error = [NSError errorWithDomain:@"MetaZ" code:12 userInfo:dict]; + + [self dataProvider:nil controller:self loadedMeta:nil fromFile:fileName error:error]; +} + +- (BOOL)isFinished +{ + return YES; +} + +- (void)cancel +{ +} + +@end + + @implementation MZSearchDelegate @synthesize performedSearches; @synthesize finishedSearches;