From 45e2402e5f274cb9b15789bc55ed49fdfeac4960 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Thu, 17 Nov 2022 20:36:33 +0100 Subject: [PATCH] updated to Sparkle 2 --- MacPass/Base.lproj/UpdatePreferences.xib | 12 ++++++------ MacPass/MPAppDelegate.h | 2 ++ MacPass/MPAppDelegate.m | 7 +++++-- MacPass/MPUpdatePreferencesController.m | 11 ++++++++--- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/MacPass/Base.lproj/UpdatePreferences.xib b/MacPass/Base.lproj/UpdatePreferences.xib index 410ca3c67..9789b4edd 100644 --- a/MacPass/Base.lproj/UpdatePreferences.xib +++ b/MacPass/Base.lproj/UpdatePreferences.xib @@ -1,8 +1,8 @@ - + - + @@ -16,10 +16,10 @@ - + - + - + diff --git a/MacPass/MPAppDelegate.h b/MacPass/MPAppDelegate.h index caf9f770a..bdf64b8de 100644 --- a/MacPass/MPAppDelegate.h +++ b/MacPass/MPAppDelegate.h @@ -25,6 +25,7 @@ APPKIT_EXTERN NSString *const MPDidChangeStoredKeyFilesSettings; @class MPEntryContextMenuDelegate; +@class SPUUpdater; @interface MPAppDelegate : NSObject @@ -36,6 +37,7 @@ APPKIT_EXTERN NSString *const MPDidChangeStoredKeyFilesSettings; @property (strong) IBOutlet NSMenu *exportMenu; @property (strong, readonly) MPEntryContextMenuDelegate *itemActionMenuDelegate; +@property (strong, readonly) SPUUpdater *updater; @property (readonly) BOOL isTerminating; @property (nonatomic) BOOL isAllowedToStoreKeyFile; diff --git a/MacPass/MPAppDelegate.m b/MacPass/MPAppDelegate.m index 5ab89a6d2..90bbf441c 100644 --- a/MacPass/MPAppDelegate.m +++ b/MacPass/MPAppDelegate.m @@ -67,6 +67,7 @@ @interface MPAppDelegate () { } @property (strong) NSWindow *welcomeWindow; +@property (strong) SPUUpdater *updater; @property (strong) IBOutlet NSWindow *passwordCreatorWindow; @property (strong, nonatomic) MPPreferencesWindowController *preferencesController; @property (strong, nonatomic) MPPasswordCreatorViewController *passwordCreatorController; @@ -217,7 +218,9 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification { [MPPluginHost sharedHost]; #if !defined(DEBUG) && !defined(NO_SPARKLE) /* Disable updates if in debug or nosparkle */ - [SUUpdater sharedUpdater]; + SPUStandardUserDriver *userDriver = [[SPUStandardUserDriver alloc] initWithHostBundle:NSBundle.mainBundle delegate:nil]; + self.updater = [[SPUUpdater alloc] initWithHostBundle:NSBundle.mainBundle applicationBundle:NSBundle.mainBundle userDriver:userDriver delegate:nil]; + [self.updater startUpdater:nil]; #endif self.startupState |= MPAppStartupStateFinishedLaunch; // Here we just opt-in for allowing our bar to be customized throughout the app. @@ -364,7 +367,7 @@ - (void)checkForUpdates:(id)sender { [alert addButtonWithTitle:NSLocalizedString(@"OK", @"Ok Button to dismiss disabled updates alert")]; [alert runModal]; #else - [[SUUpdater sharedUpdater] checkForUpdates:sender]; + [self.updater checkForUpdates]; #endif } diff --git a/MacPass/MPUpdatePreferencesController.m b/MacPass/MPUpdatePreferencesController.m index 9a1c9c1ee..180e4ba85 100644 --- a/MacPass/MPUpdatePreferencesController.m +++ b/MacPass/MPUpdatePreferencesController.m @@ -21,6 +21,10 @@ // #import "MPUpdatePreferencesController.h" +#import "MPAppDelegate.h" + +#import "NSApplication+MPAdditions.h" + #import @interface MPUpdatePreferencesController () @@ -53,9 +57,10 @@ - (void)awakeFromNib { 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]; + SPUUpdater *updater = NSApplication.sharedApplication.mp_delegate.updater; + [self.checkIntervallPopupButton bind:NSSelectedTagBinding toObject:updater withKeyPath:NSStringFromSelector(@selector(updateCheckInterval)) options:nil]; + [self.checkIntervallPopupButton bind:NSEnabledBinding toObject:updater withKeyPath:NSStringFromSelector(@selector(automaticallyChecksForUpdates)) options:nil]; + [self.automaticallyCheckForUpdatesCheckButton bind:NSValueBinding toObject:updater withKeyPath:NSStringFromSelector(@selector(automaticallyChecksForUpdates)) options:nil]; #endif }