diff --git a/MacPass.xcodeproj/project.pbxproj b/MacPass.xcodeproj/project.pbxproj index 0818e0b6..1d6dd70e 100644 --- a/MacPass.xcodeproj/project.pbxproj +++ b/MacPass.xcodeproj/project.pbxproj @@ -264,6 +264,7 @@ 4CE8246F16E2E93400573141 /* MPOverlayWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE8246E16E2E93400573141 /* MPOverlayWindowController.m */; }; 4CE8247516E2F2B900573141 /* MPOverlayView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE8247416E2F2B900573141 /* MPOverlayView.m */; }; 4CE88B9717BA651C0042E078 /* contextTriangleTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4CE88B9617BA651C0042E078 /* contextTriangleTemplate.pdf */; }; + 4CE97BAA216FA968006BF25D /* MPPluginBrowserTableCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE97BA9216FA968006BF25D /* MPPluginBrowserTableCellView.m */; }; 4CEE46DD181C301D006BF1E5 /* MPAutotypeDaemon.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CEE46DC181C301D006BF1E5 /* MPAutotypeDaemon.m */; }; 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 */; }; @@ -823,6 +824,8 @@ 4CE88B9617BA651C0042E078 /* contextTriangleTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; name = contextTriangleTemplate.pdf; path = Icons/contextTriangleTemplate.pdf; sourceTree = ""; }; 4CE88C2417C163FE00BFD195 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; }; 4CE88C3317C1647400BFD195 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 4CE97BA8216FA968006BF25D /* MPPluginBrowserTableCellView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MPPluginBrowserTableCellView.h; sourceTree = ""; }; + 4CE97BA9216FA968006BF25D /* MPPluginBrowserTableCellView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MPPluginBrowserTableCellView.m; sourceTree = ""; }; 4CEE46DB181C301D006BF1E5 /* MPAutotypeDaemon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPAutotypeDaemon.h; sourceTree = ""; }; 4CEE46DC181C301D006BF1E5 /* MPAutotypeDaemon.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPAutotypeDaemon.m; sourceTree = ""; }; 4CEED1C417D7BD0E007180F1 /* NSError+Messages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSError+Messages.h"; sourceTree = ""; }; @@ -1048,6 +1051,8 @@ 4C0F043F2147A6FA000B8568 /* MPCustomFieldTableView.m */, 4C370EFC215B76CB00703AAE /* MPOutlineTableCellView.h */, 4C370EFD215B76CB00703AAE /* MPOutlineTableCellView.m */, + 4CE97BA8216FA968006BF25D /* MPPluginBrowserTableCellView.h */, + 4CE97BA9216FA968006BF25D /* MPPluginBrowserTableCellView.m */, ); name = Views; sourceTree = ""; @@ -1948,6 +1953,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 4CE97BAA216FA968006BF25D /* MPPluginBrowserTableCellView.m in Sources */, 4CD034AC1BFE113B003C002C /* MPPluginHost.m in Sources */, 4C77E37315B84A240093A587 /* main.m in Sources */, 4C0F04402147A6FA000B8568 /* MPCustomFieldTableView.m in Sources */, diff --git a/MacPass/MPPluginBrowserTableCellView.h b/MacPass/MPPluginBrowserTableCellView.h new file mode 100644 index 00000000..234148e0 --- /dev/null +++ b/MacPass/MPPluginBrowserTableCellView.h @@ -0,0 +1,19 @@ +// +// MPPluginBrowserTableCellView.h +// MacPass +// +// Created by Michael Starke on 11.10.18. +// Copyright © 2018 HicknHack Software GmbH. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface MPPluginBrowserTableCellView : NSTableCellView + +@property (strong) IBOutlet NSTextField *statusTextField; + +@end + +NS_ASSUME_NONNULL_END diff --git a/MacPass/MPPluginBrowserTableCellView.m b/MacPass/MPPluginBrowserTableCellView.m new file mode 100644 index 00000000..85f919e0 --- /dev/null +++ b/MacPass/MPPluginBrowserTableCellView.m @@ -0,0 +1,27 @@ +// +// MPPluginBrowserTableCellView.m +// MacPass +// +// Created by Michael Starke on 11.10.18. +// Copyright © 2018 HicknHack Software GmbH. All rights reserved. +// + +#import "MPPluginBrowserTableCellView.h" + +@implementation MPPluginBrowserTableCellView + +- (void)setBackgroundStyle:(NSBackgroundStyle)backgroundStyle { + super.backgroundStyle = backgroundStyle; + switch(backgroundStyle) { + case NSBackgroundStyleNormal: + case NSBackgroundStyleLowered: + self.statusTextField.textColor = NSColor.controlTextColor; + break; + case NSBackgroundStyleRaised: + case NSBackgroundStyleEmphasized: + self.statusTextField.textColor = NSColor.selectedControlTextColor; + break; + } +} + +@end diff --git a/MacPass/MPPluginHost.h b/MacPass/MPPluginHost.h index 8d47f1b6..3830f533 100644 --- a/MacPass/MPPluginHost.h +++ b/MacPass/MPPluginHost.h @@ -50,9 +50,6 @@ FOUNDATION_EXPORT NSString *const MPPluginHostPluginBundleIdentifiyerKey; - (void)loadPlugins; -/* -- (NSArray *)autotypePlugins; -- (NSArray *)entryContextMenuPlugins; -*/ +- (MPPlugin *)pluginWithBundleIdentifier:(NSString *)identifer; - (NSArray *)avilableMenuItemsForEntries:(NSArray *)entries; @end diff --git a/MacPass/MPPluginHost.m b/MacPass/MPPluginHost.m index b3f1831e..7ca9f85a 100644 --- a/MacPass/MPPluginHost.m +++ b/MacPass/MPPluginHost.m @@ -129,6 +129,16 @@ NSString *const MPPluginHostPluginBundleIdentifiyerKey = @"MPPluginHostPluginBun } +- (MPPlugin *)pluginWithBundleIdentifier:(NSString *)identifer { + for(MPPlugin *plugin in self.mutablePlugins) { + if([plugin.bundle.bundleIdentifier isEqualToString:identifer]) { + return plugin; + } + } + return nil; + +} + #pragma mark - Plugin Loading - (void)loadPlugins { @@ -253,13 +263,7 @@ NSString *const MPPluginHostPluginBundleIdentifiyerKey = @"MPPluginHostPluginBun } - (BOOL)_validateUniqueBundle:(NSBundle *)bundle { - for(MPPlugin *plugin in self.mutablePlugins) { - NSBundle *pluginBundle = [NSBundle bundleForClass:plugin.class]; - if([pluginBundle.bundleIdentifier isEqualToString:bundle.bundleIdentifier]) { - return YES; - } - } - return NO; + return ![self pluginWithBundleIdentifier:bundle.bundleIdentifier]; } - (BOOL)_isCompatiblePluginBundle:(NSBundle *)bundle avaiablePlugins:(NSArray *)availablePlugins { diff --git a/MacPass/MPPluginRepositoryBrowserViewController.m b/MacPass/MPPluginRepositoryBrowserViewController.m index 60707764..f15afb44 100644 --- a/MacPass/MPPluginRepositoryBrowserViewController.m +++ b/MacPass/MPPluginRepositoryBrowserViewController.m @@ -7,12 +7,11 @@ // #import "MPPluginRepositoryBrowserViewController.h" +#import "MPPlugin.h" +#import "MPPluginHost.h" #import "MPPluginRepository.h" #import "MPPluginRepositoryItem.h" - -NSString *MPPluginBrowserColumnName = @"MPPluginBrowserColumnName"; -NSString *MPPluginBrowserColumnCurrentVersion = @"MPPluginBrowserColumnCurrentVersion"; -NSString *MPPluginBrowserColumnInstalledVersion = @"MPPluginBrowserColumnInstalledVersion"; +#import "MPPluginBrowserTableCellView.h" @interface MPPluginRepositoryBrowserViewController () @@ -28,11 +27,6 @@ NSString *MPPluginBrowserColumnInstalledVersion = @"MPPluginBrowserColumnInstall } - (void)viewDidLoad { - - self.itemTable.tableColumns[0].identifier = MPPluginBrowserColumnName; - self.itemTable.tableColumns[1].identifier = MPPluginBrowserColumnCurrentVersion; - self.itemTable.tableColumns[2].identifier = MPPluginBrowserColumnInstalledVersion; - [super viewDidLoad]; [self _refreshRepository]; } @@ -50,20 +44,22 @@ NSString *MPPluginBrowserColumnInstalledVersion = @"MPPluginBrowserColumnInstall } - (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { - + MPPluginBrowserTableCellView *view = [tableView makeViewWithIdentifier:tableColumn.identifier owner:self]; MPPluginRepositoryItem *item = self.repositoryItems.firstObject; - if([tableColumn.identifier isEqualToString:MPPluginBrowserColumnName]) { - NSTableCellView *view = [tableView makeViewWithIdentifier:@"NameCellView" owner:self]; - view.textField.stringValue = item.name; - return view; + view.textField.stringValue = item.name; + + MPPlugin *plugin = [MPPluginHost.sharedHost pluginWithBundleIdentifier:item.bundleIdentifier]; + if(plugin) { + if([plugin.humanVersionString isEqualToString:item.currentVersion]) { + view.statusTextField.stringValue = [NSString stringWithFormat:NSLocalizedString(@"INSTALLED_VERSION_%@_(UP_TO_DATE)", "Info displayed when an installed plugin is up to date"), plugin.humanVersionString]; + } + else { + view.statusTextField.stringValue = [NSString stringWithFormat:NSLocalizedString(@"CURRENT_VERSION_%@_(INSTALLED_VERSION_%@)", "Info displayed when a plugin is loaded and "), item.currentVersion, plugin.humanVersionString]; + } } - if([tableColumn.identifier isEqualToString:MPPluginBrowserColumnCurrentVersion]) { - NSTableCellView *view = [tableView makeViewWithIdentifier:@"CurrentVersionCellView" owner:self]; - view.textField.stringValue = item.currentVersion; - return view; + else { + view.statusTextField.stringValue = [NSString stringWithFormat:NSLocalizedString(@"CURRENT_VERSION_%@_(NOT_INSTALLED)", "Info displayed when an plugin is not installed"), plugin.humanVersionString]; } - NSTableCellView *view = [tableView makeViewWithIdentifier:@"InstalledVersionCellView" owner:self]; - view.textField.stringValue = item.descriptionText; return view; } diff --git a/MacPass/MPPluginTabelCellView.h b/MacPass/MPPluginTabelCellView.h index ff5dd11c..c8dca336 100644 --- a/MacPass/MPPluginTabelCellView.h +++ b/MacPass/MPPluginTabelCellView.h @@ -24,6 +24,6 @@ @interface MPPluginTabelCellView : NSTableCellView -@property (weak) IBOutlet NSTextField *addionalTextField; +@property (strong) IBOutlet NSTextField *addionalTextField; @end diff --git a/MacPass/MPPluginTabelCellView.m b/MacPass/MPPluginTabelCellView.m index 5073498b..e0e4e000 100644 --- a/MacPass/MPPluginTabelCellView.m +++ b/MacPass/MPPluginTabelCellView.m @@ -24,4 +24,9 @@ @implementation MPPluginTabelCellView +- (void)setBackgroundStyle:(NSBackgroundStyle)backgroundStyle { + super.backgroundStyle = backgroundStyle; + self.addionalTextField.cell.backgroundStyle = backgroundStyle; +} + @end diff --git a/MacPass/PluginRepositoryBrowserView.xib b/MacPass/PluginRepositoryBrowserView.xib index eac8b69c..9da97920 100644 --- a/MacPass/PluginRepositoryBrowserView.xib +++ b/MacPass/PluginRepositoryBrowserView.xib @@ -18,20 +18,20 @@ - + - + - + @@ -44,88 +44,39 @@ - - + + - - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -187,7 +138,7 @@ - +