This commit is contained in:
mrdoggy
2016-01-05 22:04:13 +03:00
12 changed files with 132 additions and 24 deletions

View File

@@ -9,6 +9,8 @@
#import "MPAutotypeCommand.h"
@interface MPAutotypeDelay : MPAutotypeCommand
@property (readonly) NSUInteger delay;
/**
* Creates an DelayCommand that delays the execution for n milliseconds
*

View File

@@ -8,10 +8,8 @@
#import "MPAutotypeDelay.h"
@interface MPAutotypeDelay () {
@private
NSUInteger _delay;
}
@interface MPAutotypeDelay ()
@property (readwrite) NSUInteger delay;
@end
@implementation MPAutotypeDelay
@@ -22,7 +20,7 @@
}
- (NSString *)description {
return [[NSString alloc] initWithFormat:@"%@ delay: %ld ms", self.class, _delay];
return [[NSString alloc] initWithFormat:@"%@ delay: %ld ms", self.class, self.delay];
}
- (instancetype)initWithDelay:(NSUInteger)delay {
@@ -36,7 +34,7 @@
- (void)execute {
/* milliseconds * 10000 = microseconds */
usleep((useconds_t)(_delay*1000));
usleep((useconds_t)(self.delay*1000));
}
@end

View File

@@ -21,7 +21,7 @@
//
#import <Cocoa/Cocoa.h>
#import "KeePassKit/KeePassKit.h"
#import <KeePassKit/KeePassKit.h>
#import "MPEntrySearchContext.h"
#import "MPTargetNodeResolving.h"

View File

@@ -35,5 +35,21 @@ FOUNDATION_EXPORT NSString *const kMPPluginFileExtension;
@end
@class KPKTree;
@protocol MPTreeImporting <NSObject>
@required
- (KPKTree *)importTreeAtURL:(NSURL *)url error:(NSError **)error;
@end
@protocol MPTreeExporting <NSObject>
@required
- (NSData *)dataForTree:(KPKTree *)tree error:(NSError **)error;
@end
NS_ASSUME_NONNULL_END

View File

@@ -43,10 +43,6 @@ NSString *const MPPluginManagerPluginBundleIdentifiyerKey = @"MPPluginManagerPlu
return instance;
}
- (void)dealloc {
NSLog(@"%@ dealloc", [self class]);
}
- (instancetype)init {
return nil;
}
@@ -71,16 +67,30 @@ NSString *const MPPluginManagerPluginBundleIdentifiyerKey = @"MPPluginManagerPlu
}
- (void)_loadPlugins {
NSURL *dir = [NSApp applicationSupportDirectoryURL:YES];
NSURL *appSupportDir = [NSApp applicationSupportDirectoryURL:YES];
NSError *error;
NSArray *contentURLs = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:dir
NSArray *externalPluginsURLs = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:appSupportDir
includingPropertiesForKeys:@[]
options:NSDirectoryEnumerationSkipsHiddenFiles
error:&error];
if(!contentURLs) {
NSLog(@"Error while trying to locate Plugins: %@", error.localizedDescription);
NSArray *internalPluginsURLs = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:[NSBundle mainBundle].builtInPlugInsURL
includingPropertiesForKeys:@[]
options:NSDirectoryEnumerationSkipsHiddenFiles
error:&error];
if(!externalPluginsURLs) {
// No external plugins
NSLog(@"No external plugins found!");
}
for(NSURL *pluginURL in contentURLs) {
if(!internalPluginsURLs) {
// No internal plugins
NSLog(@"No internal plugins found!");
}
NSArray *pluginURLs = [externalPluginsURLs arrayByAddingObjectsFromArray:internalPluginsURLs];
for(NSURL *pluginURL in pluginURLs) {
if(![self _validURL:pluginURL]) {
continue;
@@ -113,12 +123,16 @@ NSString *const MPPluginManagerPluginBundleIdentifiyerKey = @"MPPluginManagerPlu
MPPlugin *plugin = [[pluginBundle.principalClass alloc] initWithPluginManager:self];
if(plugin) {
NSLog(@"Loaded plugin instance %@", pluginBundle.principalClass);
[[NSNotificationCenter defaultCenter] postNotificationName:MPPluginManagerWillLoadPlugin object:self userInfo:@{ MPPluginManagerPluginBundleIdentifiyerKey : plugin.identifier }];
[[NSNotificationCenter defaultCenter] postNotificationName:MPPluginManagerWillLoadPlugin
object:self
userInfo:@{ MPPluginManagerPluginBundleIdentifiyerKey : plugin.identifier }];
[self.mutablePlugins addObject:plugin];
[[NSNotificationCenter defaultCenter] postNotificationName:MPPluginManagerDidLoadPlugin object:self userInfo:@{ MPPluginManagerPluginBundleIdentifiyerKey : plugin.identifier }];
[[NSNotificationCenter defaultCenter] postNotificationName:MPPluginManagerDidLoadPlugin
object:self
userInfo:@{ MPPluginManagerPluginBundleIdentifiyerKey : plugin.identifier }];
}
else {
NSLog(@"Unable to instanciate instance of plugin class %@", pluginBundle.principalClass);
NSLog(@"Unable to create instance of plugin class %@", pluginBundle.principalClass);
}
}
}

Binary file not shown.