diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index 1c3b2621..6c3c6364 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -42,7 +42,6 @@ 4C2E381F16D11FF900037A9D /* 05_LanguagesTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C2E381C16D11FF900037A9D /* 05_LanguagesTemplate.pdf */; }; 4C2E382316D1421B00037A9D /* MPIconHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C2E382216D1421B00037A9D /* MPIconHelper.m */; }; 4C2E382616D1470200037A9D /* MPViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C2E382516D1470200037A9D /* MPViewController.m */; }; - 4C31FEB31B57CDDB008E7CE3 /* MPPluginManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C31FEB21B57CDDB008E7CE3 /* MPPluginManager.m */; }; 4C32B0E71A1D4436007E12F1 /* KPKFormat+MPUTIDetection.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C32B0E61A1D4436007E12F1 /* KPKFormat+MPUTIDetection.m */; }; 4C3666411787327E00B249F1 /* MPDocument+Attachments.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C3666401787327E00B249F1 /* MPDocument+Attachments.m */; }; 4C37A84015B8B474005EF8EE /* MPOutlineDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C37A83F15B8B474005EF8EE /* MPOutlineDataSource.m */; }; @@ -205,6 +204,9 @@ 4CCEDE2E179F213B008402BE /* MPNotifications.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CCEDE2D179F213B008402BE /* MPNotifications.m */; }; 4CCFA13D1BF0CC7A0078E0A1 /* Test_Password_1234.kdb in Resources */ = {isa = PBXBuildFile; fileRef = 4CCFA1321BF0CC7A0078E0A1 /* Test_Password_1234.kdb */; }; 4CCFA13E1BF0CC7A0078E0A1 /* Test_Password_1234.kdbx in Resources */ = {isa = PBXBuildFile; fileRef = 4CCFA1331BF0CC7A0078E0A1 /* Test_Password_1234.kdbx */; }; + 4CD034AA1BFE113B003C002C /* MPPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CD034A51BFE113B003C002C /* MPPlugin.m */; }; + 4CD034AB1BFE113B003C002C /* MPPluginHost.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CD034A71BFE113B003C002C /* MPPluginHost.m */; }; + 4CD034AC1BFE113B003C002C /* MPPluginManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CD034A91BFE113B003C002C /* MPPluginManager.m */; }; 4CD2B9061849424B0051B395 /* MPAutotypeContext.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CD2B9051849424B0051B395 /* MPAutotypeContext.m */; }; 4CD5D705177A5F3300100649 /* MPDatabaseSettingsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CD5D704177A5F3300100649 /* MPDatabaseSettingsWindowController.m */; }; 4CD7223B17A7CB0700F5A1E1 /* MPWorkflowSettingsController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CD7223A17A7CB0700F5A1E1 /* MPWorkflowSettingsController.m */; }; @@ -232,7 +234,6 @@ 4CEED1C617D7BD0E007180F1 /* NSError+Messages.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CEED1C517D7BD0E007180F1 /* NSError+Messages.m */; }; 4CF29BF417879D0000851B60 /* 26_FileSaveTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4CF29BF317879D0000851B60 /* 26_FileSaveTemplate.pdf */; }; 4CF5BE6D1BF33E3000048505 /* NSApplication+MPAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF5BE6C1BF33E3000048505 /* NSApplication+MPAdditions.m */; }; - 4CF5BEC41BF3461800048505 /* MPPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF5BEC31BF3461800048505 /* MPPlugin.m */; }; 4CF6C711176F4533007A811D /* MPStringLengthValueTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF6C710176F4533007A811D /* MPStringLengthValueTransformer.m */; }; 4CF78064176E75AD0032EE71 /* MPIntegrationSettingsController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF78063176E75AD0032EE71 /* MPIntegrationSettingsController.m */; }; 4CFB18E418A17FA20097A34B /* MPUpdateSettingsController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CFB18E318A17FA20097A34B /* MPUpdateSettingsController.m */; }; @@ -413,8 +414,6 @@ 4C2E382216D1421B00037A9D /* MPIconHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPIconHelper.m; sourceTree = ""; }; 4C2E382416D1470200037A9D /* MPViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPViewController.h; sourceTree = ""; }; 4C2E382516D1470200037A9D /* MPViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPViewController.m; sourceTree = ""; }; - 4C31FEB11B57CDDB008E7CE3 /* MPPluginManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPPluginManager.h; sourceTree = ""; }; - 4C31FEB21B57CDDB008E7CE3 /* MPPluginManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPPluginManager.m; sourceTree = ""; }; 4C32B0E51A1D4436007E12F1 /* KPKFormat+MPUTIDetection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "KPKFormat+MPUTIDetection.h"; sourceTree = ""; }; 4C32B0E61A1D4436007E12F1 /* KPKFormat+MPUTIDetection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "KPKFormat+MPUTIDetection.m"; sourceTree = ""; }; 4C3666401787327E00B249F1 /* MPDocument+Attachments.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MPDocument+Attachments.m"; sourceTree = ""; }; @@ -673,6 +672,12 @@ 4CCEDE2D179F213B008402BE /* MPNotifications.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPNotifications.m; sourceTree = ""; }; 4CCFA1321BF0CC7A0078E0A1 /* Test_Password_1234.kdb */ = {isa = PBXFileReference; lastKnownFileType = file; path = Test_Password_1234.kdb; sourceTree = ""; }; 4CCFA1331BF0CC7A0078E0A1 /* Test_Password_1234.kdbx */ = {isa = PBXFileReference; lastKnownFileType = file; path = Test_Password_1234.kdbx; sourceTree = ""; }; + 4CD034A41BFE113B003C002C /* MPPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MPPlugin.h; path = MacPass/MPPlugin.h; sourceTree = SOURCE_ROOT; }; + 4CD034A51BFE113B003C002C /* MPPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MPPlugin.m; path = MacPass/MPPlugin.m; sourceTree = SOURCE_ROOT; }; + 4CD034A61BFE113B003C002C /* MPPluginHost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MPPluginHost.h; path = MacPass/MPPluginHost.h; sourceTree = SOURCE_ROOT; }; + 4CD034A71BFE113B003C002C /* MPPluginHost.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MPPluginHost.m; path = MacPass/MPPluginHost.m; sourceTree = SOURCE_ROOT; }; + 4CD034A81BFE113B003C002C /* MPPluginManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MPPluginManager.h; path = MacPass/MPPluginManager.h; sourceTree = SOURCE_ROOT; }; + 4CD034A91BFE113B003C002C /* MPPluginManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MPPluginManager.m; path = MacPass/MPPluginManager.m; sourceTree = SOURCE_ROOT; }; 4CD2B9041849424B0051B395 /* MPAutotypeContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPAutotypeContext.h; sourceTree = ""; }; 4CD2B9051849424B0051B395 /* MPAutotypeContext.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPAutotypeContext.m; sourceTree = ""; }; 4CD5D703177A5F3300100649 /* MPDatabaseSettingsWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPDatabaseSettingsWindowController.h; sourceTree = ""; }; @@ -720,8 +725,6 @@ 4CF29BF317879D0000851B60 /* 26_FileSaveTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 26_FileSaveTemplate.pdf; sourceTree = ""; }; 4CF5BE6B1BF33E3000048505 /* NSApplication+MPAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSApplication+MPAdditions.h"; sourceTree = ""; }; 4CF5BE6C1BF33E3000048505 /* NSApplication+MPAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSApplication+MPAdditions.m"; sourceTree = ""; }; - 4CF5BEC21BF3461800048505 /* MPPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPPlugin.h; sourceTree = ""; }; - 4CF5BEC31BF3461800048505 /* MPPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPPlugin.m; sourceTree = ""; }; 4CF6C70F176F4533007A811D /* MPStringLengthValueTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPStringLengthValueTransformer.h; sourceTree = ""; }; 4CF6C710176F4533007A811D /* MPStringLengthValueTransformer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPStringLengthValueTransformer.m; sourceTree = ""; }; 4CF78062176E75AD0032EE71 /* MPIntegrationSettingsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPIntegrationSettingsController.h; sourceTree = ""; }; @@ -950,17 +953,6 @@ name = Helper; sourceTree = ""; }; - 4C31FEBC1B57CDE0008E7CE3 /* Plugin */ = { - isa = PBXGroup; - children = ( - 4C31FEB11B57CDDB008E7CE3 /* MPPluginManager.h */, - 4C31FEB21B57CDDB008E7CE3 /* MPPluginManager.m */, - 4CF5BEC21BF3461800048505 /* MPPlugin.h */, - 4CF5BEC31BF3461800048505 /* MPPlugin.m */, - ); - name = Plugin; - sourceTree = ""; - }; 4C37A84115B8B47D005EF8EE /* Delegates */ = { isa = PBXGroup; children = ( @@ -1238,7 +1230,7 @@ 4C77E36C15B84A240093A587 /* MacPass */ = { isa = PBXGroup; children = ( - 4C31FEBC1B57CDE0008E7CE3 /* Plugin */, + 4CF9ECAE1BFDEC5700C58E99 /* Plugin */, 4C217D8E17A32BCF00609FAA /* Common */, 4C104129178CDD26001B5239 /* Categories */, 4C89F525182FB4C50069C73C /* Autotype */, @@ -1480,6 +1472,20 @@ name = PasswordInputs; sourceTree = ""; }; + 4CF9ECAE1BFDEC5700C58E99 /* Plugin */ = { + isa = PBXGroup; + children = ( + 4CD034A41BFE113B003C002C /* MPPlugin.h */, + 4CD034A51BFE113B003C002C /* MPPlugin.m */, + 4CD034A61BFE113B003C002C /* MPPluginHost.h */, + 4CD034A71BFE113B003C002C /* MPPluginHost.m */, + 4CD034A81BFE113B003C002C /* MPPluginManager.h */, + 4CD034A91BFE113B003C002C /* MPPluginManager.m */, + ); + name = Plugin; + path = MacPassPlugin; + sourceTree = SOURCE_ROOT; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -1807,8 +1813,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 4CD034AC1BFE113B003C002C /* MPPluginManager.m in Sources */, 4C77E37315B84A240093A587 /* main.m in Sources */, - 4CF5BEC41BF3461800048505 /* MPPlugin.m in Sources */, 4CBA2ABA17074C07006D8139 /* MPSettingsHelper.m in Sources */, 4C77E37A15B84A240093A587 /* MPAppDelegate.m in Sources */, 4C37A84015B8B474005EF8EE /* MPOutlineDataSource.m in Sources */, @@ -1817,6 +1823,7 @@ 4CA0B2FC15BCAF8600654E32 /* MPSettingsWindowController.m in Sources */, 4C4F72D118DF704400E8D378 /* DDHotKeyTextField.m in Sources */, 4C83814215BF4677001AE468 /* MPDocumentWindowController.m in Sources */, + 4CD034AB1BFE113B003C002C /* MPPluginHost.m in Sources */, 4C2E382316D1421B00037A9D /* MPIconHelper.m in Sources */, 4C2E382616D1470200037A9D /* MPViewController.m in Sources */, 4C65FAE916D16DDB006E0577 /* MPPasswordInputController.m in Sources */, @@ -1847,6 +1854,7 @@ 4CE296191842A166005F01CE /* MPAutotypePaste.m in Sources */, 4C569D9E17652B0600595B62 /* MPConstants.m in Sources */, 4C569DA117652BFE00595B62 /* MPEntryTableDataSource.m in Sources */, + 4CD034AA1BFE113B003C002C /* MPPlugin.m in Sources */, 4C3C4EA318D6FEA100153127 /* TTTCryptographyTransformers.m in Sources */, 4CA2335A176DBFE100F0B6AC /* MPLockDaemon.m in Sources */, 4C94A0721938DDC20040ABAB /* MPDocument+EditingSession.m in Sources */, @@ -1906,7 +1914,6 @@ 4CE2961518429AA5005F01CE /* MPAutotypeKeyPress.m in Sources */, 4C32B0E71A1D4436007E12F1 /* KPKFormat+MPUTIDetection.m in Sources */, 4CE501341BBC47F500FB819D /* MPTagsTokenFieldDelegate.m in Sources */, - 4C31FEB31B57CDDB008E7CE3 /* MPPluginManager.m in Sources */, 4C3C4EA518D6FEA100153127 /* TTTImageTransformers.m in Sources */, 4CC6DB7A17D23719002C6091 /* KPKNode+IconImage.m in Sources */, 4C15B74618BCA3B1003F8008 /* MPDocument+Search.m in Sources */, @@ -2358,6 +2365,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; SDKROOT = macosx; + STRIP_STYLE = debugging; WRAPPER_EXTENSION = app; }; name = Debug; @@ -2372,6 +2380,7 @@ COMBINE_HIDPI_IMAGES = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "MacPass/MacPass-Prefix.pch"; + GCC_SYMBOLS_PRIVATE_EXTERN = NO; INFOPLIST_FILE = "MacPass/MacPass-Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.8; @@ -2383,6 +2392,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; SDKROOT = macosx; + STRIP_STYLE = debugging; WRAPPER_EXTENSION = app; }; name = Release; diff --git a/MacPass.xcodeproj/xcshareddata/xcschemes/MacPass.xcscheme b/MacPass.xcodeproj/xcshareddata/xcschemes/MacPass.xcscheme index e5642bb1..f98c064f 100644 --- a/MacPass.xcodeproj/xcshareddata/xcschemes/MacPass.xcscheme +++ b/MacPass.xcodeproj/xcshareddata/xcschemes/MacPass.xcscheme @@ -93,6 +93,26 @@ + + + + + + + + - + @@ -17,12 +17,12 @@ - + - + - + @@ -31,7 +31,7 @@ - + - + + If enabled, only properly signed Plugins will be loaded. Keep in mind, that Plugins have full access to your data! Changes take affect on restart. - - - - + + + + - - + + - + - + - + - - + + - + - - - - - - + @@ -107,16 +103,16 @@ - - + + - - + - - - - - + + + + + - + diff --git a/MacPass/MPDocument.h b/MacPass/MPDocument.h index 84bb0af1..9c10ef8c 100644 --- a/MacPass/MPDocument.h +++ b/MacPass/MPDocument.h @@ -67,6 +67,7 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey; @property (strong, readonly, nonatomic) KPKTree *tree; @property (nonatomic, weak, readonly) KPKGroup *root; +@property (nonatomic, weak) KPKGroup *trash; @property (nonatomic, weak) KPKGroup *templates; @property (nonatomic, strong, readonly) KPKCompositeKey *compositeKey; diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index 40f655c3..9fcb5cba 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -368,9 +368,11 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey } - (void)setTemplates:(KPKGroup *)templates { - if(![self.tree.metaData.entryTemplatesGroup isEqual:templates.uuid]) { - self.tree.metaData.entryTemplatesGroup = templates.uuid; - } + self.tree.templates = templates; +} + +- (void)setTrash:(KPKGroup *)trash { + self.tree.trash = trash; } - (void)setSelectedGroup:(KPKGroup *)selectedGroup { diff --git a/MacPass/MPPlugin.h b/MacPass/MPPlugin.h index e9eb0471..4afbee61 100644 --- a/MacPass/MPPlugin.h +++ b/MacPass/MPPlugin.h @@ -23,6 +23,9 @@ FOUNDATION_EXPORT NSString *const kMPPluginFileExtension; - (instancetype)initWithPluginManager:(MPPluginManager *)manager NS_DESIGNATED_INITIALIZER; - (instancetype)init NS_UNAVAILABLE; +- (void)didLoadPlugin; +- (void)willUnloadPlugin; + @end @protocol MPPluginSettings @@ -32,4 +35,5 @@ FOUNDATION_EXPORT NSString *const kMPPluginFileExtension; @end + NS_ASSUME_NONNULL_END \ No newline at end of file diff --git a/MacPass/MPPlugin.m b/MacPass/MPPlugin.m index 949c8719..d8707576 100644 --- a/MacPass/MPPlugin.m +++ b/MacPass/MPPlugin.m @@ -45,4 +45,12 @@ NSString *const kMPPluginFileExtension = @"mpplugin"; } +- (void)didLoadPlugin { + +} + +- (void)willUnloadPlugin { + +} + @end diff --git a/MacPass/MPPluginHost.h b/MacPass/MPPluginHost.h new file mode 100644 index 00000000..36d99d33 --- /dev/null +++ b/MacPass/MPPluginHost.h @@ -0,0 +1,23 @@ +// +// MPPluginHost.h +// MacPass +// +// Created by Michael Starke on 13/11/15. +// Copyright © 2015 HicknHack Software GmbH. All rights reserved. +// + +#import +@class KPKNode; + +typedef BOOL (^NodeMatchBlock)(KPKNode *aNode); + +@interface MPPluginHost : NSObject + ++ (instancetype)sharedHost; + +- (instancetype)init NS_UNAVAILABLE; + +- (NSArray *)filteredEntriesUsingBlock:(NodeMatchBlock)matchBlock; +- (NSArray *)filteredGroupsUsingBlock:(NodeMatchBlock)matchBlock; + +@end diff --git a/MacPass/MPPluginHost.m b/MacPass/MPPluginHost.m new file mode 100644 index 00000000..9abb7b80 --- /dev/null +++ b/MacPass/MPPluginHost.m @@ -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 diff --git a/MacPass/MPPluginManager.h b/MacPass/MPPluginManager.h index 6a2649b0..389a8b3e 100644 --- a/MacPass/MPPluginManager.h +++ b/MacPass/MPPluginManager.h @@ -23,13 +23,8 @@ FOUNDATION_EXPORT NSString *const MPPluginManagerPluginBundleIdentifiyerKey; @property (readonly, copy) NSArray *plugins; @property (nonatomic, readonly) BOOL loadUnsecurePlugins; -typedef BOOL (^NodeMatchBlock)(KPKNode *aNode); - + (instancetype)sharedManager; - (instancetype)init NS_UNAVAILABLE; -- (NSArray *)filteredEntriesUsingBlock:(NodeMatchBlock) matchBlock; -- (NSArray *)filteredGroupsUsingBlock:(NodeMatchBlock) matchBlock; - @end diff --git a/MacPass/MPPluginManager.m b/MacPass/MPPluginManager.m index 6aa6d1fc..58b9f00e 100644 --- a/MacPass/MPPluginManager.m +++ b/MacPass/MPPluginManager.m @@ -8,7 +8,6 @@ #import "MPPluginManager.h" -#import "MPDocument.h" #import "MPPlugin.h" #import "NSApplication+MPAdditions.h" #import "MPSettingsHelper.h" @@ -46,6 +45,10 @@ NSString *const MPPluginManagerPluginBundleIdentifiyerKey = @"MPPluginManagerPlu return instance; } +- (void)dealloc { + NSLog(@"%@ dealloc", [self class]); +} + - (instancetype)init { return nil; } @@ -65,38 +68,17 @@ NSString *const MPPluginManagerPluginBundleIdentifiyerKey = @"MPPluginManagerPlu return self; } -- (void)setLoadUnsecurePlugins:(BOOL)loadUnsecurePlugins { - if(_loadUnsecurePlugins != loadUnsecurePlugins) { - _loadUnsecurePlugins = loadUnsecurePlugins; - [self _loadPlugins]; - } -} - - (NSArray *)plugins { return [self.mutablePlugins copy]; } -- (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; -} - - (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]; @@ -105,15 +87,13 @@ NSString *const MPPluginManagerPluginBundleIdentifiyerKey = @"MPPluginManagerPlu } [self.mutablePlugins removeAllObjects]; for(NSBundle *bundle in bundles) { - [bundle unload]; NSString *identifiery = bundle.bundleIdentifier ? bundle.bundleIdentifier : @"unknown"; [[NSNotificationCenter defaultCenter] postNotificationName:MPPluginManagerDidUnloadPlugin object:self userInfo:@{ MPPluginManagerPluginBundleIdentifiyerKey : identifiery }]; + [bundle unload]; } } - (void)_loadPlugins { - /* unload all plugins just to be sure */ - [self _unloadPlugins]; NSURL *dir = [NSApp applicationSupportDirectoryURL:YES]; NSError *error; NSArray *contentURLs = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:dir @@ -137,6 +117,11 @@ NSString *const MPPluginManagerPluginBundleIdentifiyerKey = @"MPPluginManagerPlu if(!pluginBundle) { continue; } + NSError *error; + if(![pluginBundle preflightAndReturnError:&error]) { + NSLog(@"%@", error.localizedDescription ); + continue; + }; if(![self _validateClass:pluginBundle.principalClass]) { continue; diff --git a/MacPass/MacPass-Info.plist b/MacPass/MacPass-Info.plist index 47ffc93a..843a0345 100644 --- a/MacPass/MacPass-Info.plist +++ b/MacPass/MacPass-Info.plist @@ -62,7 +62,7 @@ CFBundleSignature ???? CFBundleVersion - 2562 + 2567 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSAppTransportSecurity