Removed unloading code as it seems to be unsafe

Signed-off-by: michael starke <michael.starke@hicknhack-software.com>
This commit is contained in:
michael starke
2015-11-20 16:34:14 +01:00
parent c7a0cfabd1
commit 8babca8b8d
2 changed files with 1 additions and 58 deletions

View File

@@ -17,8 +17,6 @@
NSString *const MPPluginManagerWillLoadPlugin = @"com.hicknhack.macpass.MPPluginManagerWillLoadPlugin"; NSString *const MPPluginManagerWillLoadPlugin = @"com.hicknhack.macpass.MPPluginManagerWillLoadPlugin";
NSString *const MPPluginManagerDidLoadPlugin = @"comt.hicknhack.macpass.MPPluginManagerDidLoadPlugin"; NSString *const MPPluginManagerDidLoadPlugin = @"comt.hicknhack.macpass.MPPluginManagerDidLoadPlugin";
NSString *const MPPluginManagerWillUnloadPlugin = @"com.hicknhack.macpass.MPPluginManagerWillUnloadPlugin";
NSString *const MPPluginManagerDidUnloadPlugin = @"com.hicknhack.macpass.MPPluginManagerDidUnloadPlugin";
NSString *const MPPluginManagerPluginBundleIdentifiyerKey = @"MPPluginManagerPluginBundleIdentifiyerKey"; NSString *const MPPluginManagerPluginBundleIdentifiyerKey = @"MPPluginManagerPluginBundleIdentifiyerKey";
@@ -59,7 +57,7 @@ NSString *const MPPluginManagerPluginBundleIdentifiyerKey = @"MPPluginManagerPlu
_mutablePlugins = [[NSMutableArray alloc] init]; _mutablePlugins = [[NSMutableArray alloc] init];
_loadUnsecurePlugins = [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyLoadUnsecurePlugins]; _loadUnsecurePlugins = [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyLoadUnsecurePlugins];
[self _loadPlugins]; [self _loadPlugins];
[self bind:NSStringFromSelector(@selector(loadUnsecurePlugins)) [self bind:NSStringFromSelector(@selector(loadUnsecurePlugins))
toObject:[NSUserDefaultsController sharedUserDefaultsController] toObject:[NSUserDefaultsController sharedUserDefaultsController]
withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyLoadUnsecurePlugins] withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyLoadUnsecurePlugins]
@@ -72,27 +70,6 @@ NSString *const MPPluginManagerPluginBundleIdentifiyerKey = @"MPPluginManagerPlu
return [self.mutablePlugins copy]; return [self.mutablePlugins copy];
} }
- (void)_unloadPlugins {
/* TODO Notofications for UI */
NSMutableArray *bundles = [[NSMutableArray alloc] initWithCapacity:self.mutablePlugins.count];
// clear our interal refernce
for(MPPlugin *plugin in self.mutablePlugins) {
// let the plugin know we are about to unload it
[plugin willUnloadPlugin];
NSBundle *pluginBundle = [NSBundle bundleForClass:plugin.class];
if(pluginBundle) {
[bundles addObject:pluginBundle];
[[NSNotificationCenter defaultCenter] postNotificationName:MPPluginManagerWillUnloadPlugin object:self userInfo:@{ MPPluginManagerPluginBundleIdentifiyerKey : plugin.identifier}];
}
}
[self.mutablePlugins removeAllObjects];
for(NSBundle *bundle in bundles) {
NSString *identifiery = bundle.bundleIdentifier ? bundle.bundleIdentifier : @"unknown";
[[NSNotificationCenter defaultCenter] postNotificationName:MPPluginManagerDidUnloadPlugin object:self userInfo:@{ MPPluginManagerPluginBundleIdentifiyerKey : identifiery }];
[bundle unload];
}
}
- (void)_loadPlugins { - (void)_loadPlugins {
NSURL *dir = [NSApp applicationSupportDirectoryURL:YES]; NSURL *dir = [NSApp applicationSupportDirectoryURL:YES];
NSError *error; NSError *error;

View File

@@ -24,33 +24,6 @@ NSString *const _kMPPluginTableNameColumn = @"Name";
@implementation MPPluginSettingsController @implementation MPPluginSettingsController
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if(self) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_didChangePlugins:)
name:MPPluginManagerWillLoadPlugin
object:[MPPluginManager sharedManager]];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_didChangePlugins:)
name:MPPluginManagerDidLoadPlugin
object:[MPPluginManager sharedManager]];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_didChangePlugins:)
name:MPPluginManagerWillUnloadPlugin
object:[MPPluginManager sharedManager]];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_didChangePlugins:)
name:MPPluginManagerDidUnloadPlugin
object:[MPPluginManager sharedManager]];
}
return self;
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (NSString *)nibName { - (NSString *)nibName {
return @"PluginSettings"; return @"PluginSettings";
} }
@@ -121,11 +94,4 @@ NSString *const _kMPPluginTableNameColumn = @"Name";
[self showSettingsForPlugin:[self pluginForRow:table.selectedRow]]; [self showSettingsForPlugin:[self pluginForRow:table.selectedRow]];
} }
- (void)_didChangePlugins:(NSNotification *)notification {
/* better way? */
[self.pluginTableView deselectAll:self];
[self.pluginTableView reloadData];
}
@end @end