Plugin display is now more verbose

The plugin settings now displays more information about a failed plugin instead of just not displaying anything at all.
This commit is contained in:
michael starke
2017-11-20 12:51:39 +01:00
parent ec62a3e12c
commit c33c6a8cfa
11 changed files with 194 additions and 48 deletions

View File

@@ -21,6 +21,7 @@
//
#import "MPPlugin.h"
#import "MPPlugin_Private.h"
#import "MPPluginHost.h"
#import "MPSettingsHelper.h"
@@ -28,15 +29,35 @@ NSString *const kMPPluginFileExtension = @"mpplugin";
@implementation MPPlugin
@synthesize bundle = _bundle;
- (instancetype)initWithPluginHost:(MPPluginHost *)host {
self = [super init];
if(self) {
_enabled = YES;
}
return self;
}
- (NSBundle *)bundle {
if(_enabled) {
return [NSBundle bundleForClass:self.class];
}
else {
return _bundle;
}
}
- (void)setBundle:(NSBundle *)bundle {
self.enabled = NO;
if(_bundle != bundle) {
_bundle = bundle;
}
}
- (NSString *)identifier {
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
if(bundle && bundle.bundleIdentifier) {
return bundle.bundleIdentifier;
if(self.bundle.bundleIdentifier) {
return self.bundle.bundleIdentifier;
}
return [NSString stringWithFormat:@"unknown.bundle.identifier"];
}
@@ -47,10 +68,9 @@ NSString *const kMPPluginFileExtension = @"mpplugin";
}
- (NSString *)version {
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
if(bundle) {
NSString *humanVersion = bundle.infoDictionary[@"CFBundleShortVersionString"];
NSString *version = bundle.infoDictionary[(NSString *)kCFBundleVersionKey];
if(self.bundle) {
NSString *humanVersion = self.bundle.infoDictionary[@"CFBundleShortVersionString"];
NSString *version = self.bundle.infoDictionary[(NSString *)kCFBundleVersionKey];
if(humanVersion && version) {
return [NSString stringWithFormat:@"%@ (%@)", humanVersion, version];
}