From 2af98ef3d6f409657fbabdec1e56e5c7cffff520 Mon Sep 17 00:00:00 2001 From: michael starke Date: Thu, 17 Mar 2016 17:37:40 +0100 Subject: [PATCH] Displaying dialog when Sparkle is disabled --- MacPass/Base.lproj/MainMenu.xib | 3 +++ MacPass/MPAppDelegate.h | 1 + MacPass/MPAppDelegate.m | 18 +++++++++++++++--- MacPass/MPUpdateSettingsController.m | 9 +++++---- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/MacPass/Base.lproj/MainMenu.xib b/MacPass/Base.lproj/MainMenu.xib index 05fa5a7a..b78d3df5 100644 --- a/MacPass/Base.lproj/MainMenu.xib +++ b/MacPass/Base.lproj/MainMenu.xib @@ -25,6 +25,9 @@ + + + diff --git a/MacPass/MPAppDelegate.h b/MacPass/MPAppDelegate.h index 53e3c108..800e84f3 100644 --- a/MacPass/MPAppDelegate.h +++ b/MacPass/MPAppDelegate.h @@ -34,6 +34,7 @@ APPKIT_EXTERN NSString *const MPDidChangeStoredKeyFilesSettings; @property (nonatomic, assign) BOOL isAllowedToStoreKeyFile; +- (IBAction)checkForUpdates:(id)sender; - (IBAction)showPreferences:(id)sender; - (IBAction)showPasswordCreator:(id)sender; - (IBAction)createNewDatabase:(id)sender; diff --git a/MacPass/MPAppDelegate.m b/MacPass/MPAppDelegate.m index 4567058a..39a9a071 100644 --- a/MacPass/MPAppDelegate.m +++ b/MacPass/MPAppDelegate.m @@ -36,6 +36,8 @@ #import "MPTemporaryFileStorageCenter.h" #import "MPValueTransformerHelper.h" +#import "NSApplication+MPAdditions.h" + #import "KeePassKit/KeePassKit.h" #import @@ -95,7 +97,7 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi - (void)awakeFromNib { _isAllowedToStoreKeyFile = NO; /* Update the … at the save menu */ - [[self.saveMenuItem menu] setDelegate:self]; + self.saveMenuItem.menu.delegate = self; /* We want to inform anyone about the changes to keyFile remembering */ [self bind:NSStringFromSelector(@selector(isAllowedToStoreKeyFile)) @@ -160,8 +162,8 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi [MPAutotypeDaemon defaultDaemon]; /* Create Plugin Manager */ [MPPluginManager sharedManager]; -#ifdef RELEASE - /* Only enabel updater in Release */ +#ifndef DEBUG + /* Only enable updater in Release */ [SUUpdater sharedUpdater]; #endif } @@ -227,9 +229,19 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi } - (void)showHelp:(id)sender { + /* TODO: use Info.plist for URL */ [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://github.com/mstarke/MacPass"]]; } +- (void)checkForUpdates:(id)sender { +#ifdef DEBUG + NSAlert *alert = [NSAlert alertWithMessageText:@"Updates are disabled!" defaultButton:@"Ok" alternateButton:nil otherButton:nil informativeTextWithFormat:@"Sparkle updates are only available in offical releases of %@!", NSApp.applicationName]; + [alert runModal]; +#else + [[SUUpdater sharedUpdater] checkForUpdates:sender]; +#endif +} + #pragma mark - #pragma mark Private Helper - (void)_applicationDidFinishRestoringWindows:(NSNotification *)notification { diff --git a/MacPass/MPUpdateSettingsController.m b/MacPass/MPUpdateSettingsController.m index f8bbf311..754ff71a 100644 --- a/MacPass/MPUpdateSettingsController.m +++ b/MacPass/MPUpdateSettingsController.m @@ -34,13 +34,14 @@ } - (void)awakeFromNib { -#ifdef RELEASE +/* only enable bindings to settings in release mode */ +#ifdef DEBUG + self.checkIntervallPopupButton.enabled = NO; + self.automaticallyCheckForUpdatesCheckButton.enabled = NO; +#else [self.checkIntervallPopupButton bind:NSSelectedTagBinding toObject:[SUUpdater sharedUpdater] withKeyPath:NSStringFromSelector(@selector(updateCheckInterval)) options:nil]; [self.checkIntervallPopupButton bind:NSEnabledBinding toObject:[SUUpdater sharedUpdater] withKeyPath:NSStringFromSelector(@selector(automaticallyChecksForUpdates)) options:nil]; [self.automaticallyCheckForUpdatesCheckButton bind:NSValueBinding toObject:[SUUpdater sharedUpdater] withKeyPath:NSStringFromSelector(@selector(automaticallyChecksForUpdates)) options:nil]; -#else - self.checkIntervallPopupButton.enabled = NO; - self.automaticallyCheckForUpdatesCheckButton.enabled = NO; #endif }