From 9d0dc1630df063acebf02eb0636ab86b6eb44620 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Mon, 15 Jul 2019 12:23:32 +0200 Subject: [PATCH] Added simple support for import Plugins via plugin API --- MacPass/MPAppDelegate.m | 3 +++ MacPass/MPDocumentWindowController.m | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/MacPass/MPAppDelegate.m b/MacPass/MPAppDelegate.m index f7a06b2a..aafa98f2 100644 --- a/MacPass/MPAppDelegate.m +++ b/MacPass/MPAppDelegate.m @@ -249,8 +249,11 @@ typedef NS_OPTIONS(NSInteger, MPAppStartupState) { for(MPPlugin * plugin in MPPluginHost.sharedHost.importPlugins) { NSMenuItem *importItem = [[NSMenuItem alloc] init]; [plugin prepareImportMenuItem:importItem]; + importItem.submenu = nil; // kill any potential submenu! + importItem.representedObject = plugin.identifier; importItem.target = nil; importItem.action = @selector(importFromPlugin:); + [menu addItem:importItem]; } [menu insertItem:exportXML atIndex:0]; } diff --git a/MacPass/MPDocumentWindowController.m b/MacPass/MPDocumentWindowController.m index ece7e22f..e961b59a 100644 --- a/MacPass/MPDocumentWindowController.m +++ b/MacPass/MPDocumentWindowController.m @@ -284,7 +284,7 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword); return; } NSMenuItem *menuItem = sender; - if(![menuItem.representedObject isKindOfClass:NSDictionary.class]) { + if(![menuItem.representedObject isKindOfClass:NSString.class]) { return; } @@ -292,7 +292,8 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword); if(!sheetWindow) { return; } - MPPlugin *importPlugin; + NSString *bundleIdentifier = menuItem.representedObject; + MPPlugin *importPlugin = (MPPlugin *)[MPPluginHost.sharedHost pluginWithBundleIdentifier:bundleIdentifier]; NSOpenPanel *openPanel = NSOpenPanel.openPanel; [importPlugin prepareOpenPanel:openPanel]; [openPanel beginSheetModalForWindow:sheetWindow completionHandler:^(NSModalResponse result) {