From 37ea36c8a6ce072c59f0539955ba5be4e1231c43 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Mon, 11 Feb 2019 14:06:12 +0100 Subject: [PATCH] Localized inconpatible plugins alert. Added ability to open a dedicated preferences pane --- MacPass/Base.lproj/IntegrationSettings.xib | 26 +++++------ MacPass/Base.lproj/PasswordInputView.xib | 2 +- MacPass/MPAppDelegate.h | 1 + MacPass/MPAppDelegate.m | 11 ++++- MacPass/MPPluginHost.m | 48 +++++++++++--------- MacPass/MPPreferencesWindowController.m | 2 +- MacPass/MPSettingsHelper.h | 1 + MacPass/MPSettingsHelper.m | 1 + MacPass/en.lproj/IntegrationSettings.strings | 4 +- MacPass/en.lproj/Localizable.strings | 6 +++ 10 files changed, 63 insertions(+), 39 deletions(-) diff --git a/MacPass/Base.lproj/IntegrationSettings.xib b/MacPass/Base.lproj/IntegrationSettings.xib index 66b4bb37..906a46d1 100644 --- a/MacPass/Base.lproj/IntegrationSettings.xib +++ b/MacPass/Base.lproj/IntegrationSettings.xib @@ -1,8 +1,8 @@ - + - + @@ -31,14 +31,14 @@ - + - + - + Autotype is not available, because MacPass is not allowed to control your computer. To enable Autotype, go to the Security and Privacy Preferences and add MacPass to the Accessibilty group. Changes require a restart of MacPass. @@ -47,8 +47,8 @@ - + @@ -186,18 +186,18 @@ - + - + diff --git a/MacPass/Base.lproj/PasswordInputView.xib b/MacPass/Base.lproj/PasswordInputView.xib index cc74b6bb..52a50e46 100644 --- a/MacPass/Base.lproj/PasswordInputView.xib +++ b/MacPass/Base.lproj/PasswordInputView.xib @@ -152,7 +152,7 @@ Gw - + diff --git a/MacPass/MPAppDelegate.h b/MacPass/MPAppDelegate.h index 4bffe3f1..5d09a909 100644 --- a/MacPass/MPAppDelegate.h +++ b/MacPass/MPAppDelegate.h @@ -36,6 +36,7 @@ APPKIT_EXTERN NSString *const MPDidChangeStoredKeyFilesSettings; - (IBAction)checkForUpdates:(id)sender; - (IBAction)showPreferences:(id)sender; +- (IBAction)showPluginPrefences:(id)sender; - (IBAction)showPasswordCreator:(id)sender; - (IBAction)createNewDatabase:(id)sender; - (IBAction)openDatabase:(id)sender; diff --git a/MacPass/MPAppDelegate.m b/MacPass/MPAppDelegate.m index e20d7831..257a3fb1 100644 --- a/MacPass/MPAppDelegate.m +++ b/MacPass/MPAppDelegate.m @@ -227,11 +227,20 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi #pragma mark - #pragma mark Actions + +- (void)showPluginPrefences:(id)sender { + [self _showPreferencesTab:MPPreferencesTabPlugins]; +} + - (void)showPreferences:(id)sender { + [self _showPreferencesTab:MPPreferencesTabGeneral]; +} + +- (void)_showPreferencesTab:(MPPreferencesTab)tab { if(self.preferencesController == nil) { self.preferencesController = [[MPPreferencesWindowController alloc] init]; } - [self.preferencesController showPreferences]; + [self.preferencesController showPreferencesTab:tab]; } - (void)showPasswordCreator:(id)sender { diff --git a/MacPass/MPPluginHost.m b/MacPass/MPPluginHost.m index 3e2d7ec1..0558d84b 100644 --- a/MacPass/MPPluginHost.m +++ b/MacPass/MPPluginHost.m @@ -282,29 +282,35 @@ NSString *const MPPluginHostPluginBundleIdentifiyerKey = @"MPPluginHostPluginBun } } if(incompatiblePlugins.count > 0) { - NSAlert *alert = [[NSAlert alloc] init]; - alert.messageText = NSLocalizedString(@"ALERT_INCOMPATIBLE_PLUGINS_ENCOUNTERED_MESSAGE", "Message text of the alert displayed when plugins where disabled due to incompatibilty"); - alert.informativeText = NSLocalizedString(@"ALERT_INCOMPATIBLE_PLUGINS_ENCOUNTERED_INFORMATIVE_TEXT", "Informative text of the alert displayed when plugins where disabled due to incompatibilty"); - alert.alertStyle = NSAlertStyleWarning; - alert.showsSuppressionButton = YES; - [alert addButtonWithTitle:NSLocalizedString(@"ALERT_INCOMPATIBLE_PLUGINS_ENCOUNTERED_BUTTON_OK", @"Button in dialog to leave plugin ds disabled and continiue!")]; - [alert addButtonWithTitle:NSLocalizedString(@"ALERT_INCOMPATIBLE_PLUGINS_ENCOUNTERED_BUTTON_OPEN_PREFERENCES", @"Button in dialog to open plugin preferences pane!")]; - NSModalResponse returnCode = [alert runModal]; - //BOOL suppressWarning = (alert.suppressionButton.state == NSOnState); - //[NSUserDefaults.standardUserDefaults setBool:suppressWarning forKey:kMPSettingsKeyAutotypeHideAccessibiltyWarning]; - switch(returnCode) { - case NSAlertFirstButtonReturn: { - /* ok, ignore */ - break; - } - case NSAlertSecondButtonReturn: - /* open prefs */ - [((MPAppDelegate *)NSApp.delegate) showPreferences:nil]; - break; - default: - break; + BOOL hideAlert = NO; + if(nil != [NSUserDefaults.standardUserDefaults objectForKey:kMPSettingsKeyHideIncopatiblePluginsWarning]) { + hideAlert = [NSUserDefaults.standardUserDefaults boolForKey:kMPSettingsKeyHideIncopatiblePluginsWarning]; } + if(!hideAlert) { + NSAlert *alert = [[NSAlert alloc] init]; + alert.messageText = NSLocalizedString(@"ALERT_INCOMPATIBLE_PLUGINS_ENCOUNTERED_MESSAGE", "Message text of the alert displayed when plugins where disabled due to incompatibilty"); + alert.informativeText = NSLocalizedString(@"ALERT_INCOMPATIBLE_PLUGINS_ENCOUNTERED_INFORMATIVE_TEXT", "Informative text of the alert displayed when plugins where disabled due to incompatibilty"); + alert.alertStyle = NSAlertStyleWarning; + alert.showsSuppressionButton = YES; + [alert addButtonWithTitle:NSLocalizedString(@"ALERT_INCOMPATIBLE_PLUGINS_ENCOUNTERED_BUTTON_OK", @"Button in dialog to leave plugin ds disabled and continiue!")]; + [alert addButtonWithTitle:NSLocalizedString(@"ALERT_INCOMPATIBLE_PLUGINS_ENCOUNTERED_BUTTON_OPEN_PREFERENCES", @"Button in dialog to open plugin preferences pane!")]; + NSModalResponse returnCode = [alert runModal]; + BOOL suppressWarning = (alert.suppressionButton.state == NSOnState); + [NSUserDefaults.standardUserDefaults setBool:suppressWarning forKey:kMPSettingsKeyHideIncopatiblePluginsWarning]; + switch(returnCode) { + case NSAlertFirstButtonReturn: { + /* ok, ignore */ + break; + } + case NSAlertSecondButtonReturn: + /* open prefs */ + [((MPAppDelegate *)NSApp.delegate) showPluginPrefences:nil]; + break; + default: + break; + } + } } } diff --git a/MacPass/MPPreferencesWindowController.m b/MacPass/MPPreferencesWindowController.m index e3720ceb..a1f20b53 100644 --- a/MacPass/MPPreferencesWindowController.m +++ b/MacPass/MPPreferencesWindowController.m @@ -132,7 +132,7 @@ break; } NSString *identifier; - for(id tab in self.preferencesController) { + for(id tab in self.preferencesController.allValues) { if([tab isKindOfClass:tabClass]) { identifier = tab.identifier; break; diff --git a/MacPass/MPSettingsHelper.h b/MacPass/MPSettingsHelper.h index de9fe4b1..da25aa54 100644 --- a/MacPass/MPSettingsHelper.h +++ b/MacPass/MPSettingsHelper.h @@ -83,6 +83,7 @@ APPKIT_EXTERN NSString *const kMPSettingsKeyUpdatePasswordOnTemplateEntries; APPKIT_EXTERN NSString *const kMPSettingsKeyLoadUnsecurePlugins; // If set to YES this will load all plugins regardless of their codesignature status APPKIT_EXTERN NSString *const kMPSettingsKeyDisabledPlugins; // NSArray of bundle identifiers of disabled plugins APPKIT_EXTERN NSString *const kMPSettingsKeyLoadIncompatiblePlugins; // If set to YES incompatible plugins (no version info, marked as incompatible, etc) will be loaded regardless +APPKIT_EXTERN NSString *const kMPSettingsKeyHideIncopatiblePluginsWarning; // Do not show an alert, when MacPass encounteres incompatible plugins typedef NS_ENUM(NSUInteger, MPFileChangeStrategy) { MPFileChangeStrategyAsk, diff --git a/MacPass/MPSettingsHelper.m b/MacPass/MPSettingsHelper.m index dab8612a..9fb31a7b 100644 --- a/MacPass/MPSettingsHelper.m +++ b/MacPass/MPSettingsHelper.m @@ -80,6 +80,7 @@ NSString *const kMPSettingsKeyUpdatePasswordOnTemplateEntries = @"Update NSString *const kMPSettingsKeyLoadUnsecurePlugins = @"LoadUnsecurePlugins"; NSString *const kMPSettingsKeyLoadIncompatiblePlugins = @"LoadIncompatiblePlugins"; NSString *const kMPSettingsKeyDisabledPlugins = @"DisabledPlugins"; +NSString *const kMPSettingsKeyHideIncopatiblePluginsWarning = @"HideIncopatiblePluginsWarning"; /* Deprecated */ NSString *const kMPDeprecatedSettingsKeyRememberKeyFilesForDatabases = @"kMPSettingsKeyRememberKeyFilesForDatabases"; diff --git a/MacPass/en.lproj/IntegrationSettings.strings b/MacPass/en.lproj/IntegrationSettings.strings index 032a8063..cc5838e3 100644 --- a/MacPass/en.lproj/IntegrationSettings.strings +++ b/MacPass/en.lproj/IntegrationSettings.strings @@ -16,8 +16,8 @@ /* Class = "NSTextFieldCell"; title = "Shortcut is missing Key"; ObjectID = "Lxp-wI-yQy"; */ "Lxp-wI-yQy.title" = "Shortcut is missing Key"; -/* Class = "NSButtonCell"; title = "Open Preference…"; ObjectID = "NP0-R3-m6n"; */ -"NP0-R3-m6n.title" = "Open Preference…"; +/* Class = "NSButtonCell"; title = "Open Preferences…"; ObjectID = "NP0-R3-m6n"; */ +"NP0-R3-m6n.title" = "Open Preferences…"; /* Class = "NSBox"; title = "Autotype"; ObjectID = "P9N-HM-wER"; */ "P9N-HM-wER.title" = "Autotype"; diff --git a/MacPass/en.lproj/Localizable.strings b/MacPass/en.lproj/Localizable.strings index 041343b9..6e4916aa 100644 --- a/MacPass/en.lproj/Localizable.strings +++ b/MacPass/en.lproj/Localizable.strings @@ -43,6 +43,12 @@ /* Alert message displayed when Autotype performs self check and lacks accessibilty permissions */ "ALERT_AUTOTYPE_MISSING_ACCESSIBILTY_PERMISSIONS_MESSAGE_TEXT" = "MacPass cannot perform Autotype"; +/* Button in dialog to leave plugin ds disabled and continiue! */ +"ALERT_INCOMPATIBLE_PLUGINS_ENCOUNTERED_BUTTON_OK" = "OK"; + +/* Button in dialog to open plugin preferences pane! */ +"ALERT_INCOMPATIBLE_PLUGINS_ENCOUNTERED_BUTTON_OPEN_PREFERENCES" = "Show Plugin Preferences…"; + /* Informative text of the alert displayed when plugins where disabled due to incompatibilty */ "ALERT_INCOMPATIBLE_PLUGINS_ENCOUNTERED_INFORMATIVE_TEXT" = "Some plugins where disabled, because they are not compatible with this version of MacPass. Open the plugin settings for details.";