mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-20 20:19:27 +00:00
More imporvements on the Plugin System
Signed-off-by: michael starke <michael.starke@hicknhack-software.com>
This commit is contained in:
52
MacPass/MPPluginHost.m
Normal file
52
MacPass/MPPluginHost.m
Normal file
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// MPPluginHost.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 13/11/15.
|
||||
// Copyright © 2015 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPPluginHost.h"
|
||||
#import "MPDocument.h"
|
||||
|
||||
@implementation MPPluginHost
|
||||
|
||||
static MPPluginHost *_instance;
|
||||
|
||||
+ (instancetype)sharedHost {
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
_instance = [[MPPluginHost alloc] _init];
|
||||
});
|
||||
return _instance;
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
return _instance;
|
||||
}
|
||||
|
||||
- (instancetype)_init {
|
||||
self = [super init];
|
||||
if(self) {
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSArray *)filteredEntriesUsingBlock:(NodeMatchBlock)matchBlock {
|
||||
NSArray *currentDocuments = [[NSDocumentController sharedDocumentController] documents];
|
||||
NSMutableArray *entries = [[NSMutableArray alloc] initWithCapacity:200];
|
||||
for(MPDocument *document in currentDocuments) {
|
||||
if(document.tree) {
|
||||
[entries addObjectsFromArray:document.tree.allEntries];
|
||||
}
|
||||
}
|
||||
NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) { return matchBlock(evaluatedObject); }];
|
||||
return [[NSArray alloc] initWithArray:[entries filteredArrayUsingPredicate:predicate] copyItems:YES];
|
||||
}
|
||||
|
||||
- (NSArray *)filteredGroupsUsingBlock:(NodeMatchBlock)matchBlock {
|
||||
NSAssert(NO, @"Not implemented");
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user