4242#define kToolName @" gitup"
4343#define kToolInstallPath @" /usr/local/bin/" kToolName
4444
45- @interface AppDelegate () <UNUserNotificationCenterDelegate , SUUpdaterDelegate , NSMenuItemValidation >
45+ @interface AppDelegate () <UNUserNotificationCenterDelegate , SPUUpdaterDelegate , NSMenuItemValidation >
4646@property (nonatomic , strong ) AboutWindowController* aboutWindowController;
4747@property (nonatomic , strong ) CloneWindowController* cloneWindowController;
4848@property (nonatomic , strong ) PreferencesWindowController* preferencesWindowController;
4949@property (nonatomic , strong ) WelcomeWindowController* welcomeWindowController;
5050@end
5151
5252@implementation AppDelegate {
53- SUUpdater* _updater ;
53+ SPUStandardUpdaterController* _updaterController ;
5454 BOOL _manualCheck;
5555
5656 CFMessagePortRef _messagePort;
@@ -74,7 +74,7 @@ - (CloneWindowController*)cloneWindowController {
7474
7575- (void )didChangeReleaseChannel : (BOOL )didChange {
7676 if (didChange) {
77- [_updater checkForUpdatesInBackground ];
77+ [_updaterController.updater checkForUpdatesInBackground ];
7878 }
7979}
8080
@@ -205,13 +205,14 @@ - (void)applicationDidFinishLaunching:(NSNotification*)notification {
205205#if !DEBUG
206206 // Initialize Sparkle and check for update immediately
207207 if (![[NSUserDefaults standardUserDefaults ] boolForKey: kUserDefaultsKey_DisableSparkle ]) {
208- _updater = [SUUpdater sharedUpdater ];
209- _updater.delegate = self;
210- _updater.automaticallyChecksForUpdates = YES ;
211- _updater.sendsSystemProfile = NO ;
208+ _updaterController = [[SPUStandardUpdaterController alloc ] initWithStartingUpdater: YES
209+ updaterDelegate: self
210+ userDriverDelegate: nil ];
211+ _updaterController.updater .automaticallyChecksForUpdates = YES ;
212+ _updaterController.updater .sendsSystemProfile = NO ;
212213
213214 _manualCheck = NO ;
214- [_updater checkForUpdatesInBackground ];
215+ [_updaterController.updater checkForUpdatesInBackground ];
215216 }
216217#endif
217218
@@ -369,7 +370,7 @@ - (NSDictionary*)_processToolCommand:(NSDictionary*)input {
369370
370371- (BOOL )validateMenuItem : (NSMenuItem *)menuItem {
371372 if (menuItem.action == @selector (checkForUpdates: )) {
372- return [_updater validateMenuItem: menuItem] ;
373+ return _updaterController. updater . canCheckForUpdates ;
373374 }
374375 return YES ;
375376}
@@ -480,7 +481,7 @@ - (IBAction)dimissModal:(id)sender {
480481
481482- (IBAction )checkForUpdates : (id )sender {
482483 _manualCheck = YES ;
483- [_updater checkForUpdatesInBackground ];
484+ [_updaterController checkForUpdates: sender ];
484485}
485486
486487- (IBAction )installTool : (id )sender {
@@ -529,20 +530,20 @@ - (IBAction)installTool:(id)sender {
529530 }
530531}
531532
532- #pragma mark - SUUpdaterDelegate
533+ #pragma mark - SPUUpdaterDelegate
533534
534- - (NSString *)feedURLStringForUpdater : (SUUpdater *)updater {
535+ - (NSString *)feedURLStringForUpdater : (SPUUpdater *)updater {
535536 NSString * channel = [[NSUserDefaults standardUserDefaults ] stringForKey: kUserDefaultsKey_ReleaseChannel ];
536537 return [NSString stringWithFormat: kURL_AppCast , channel];
537538}
538539
539- - (void )updater : (SUUpdater *)updater didFindValidUpdate : (SUAppcastItem*)item {
540+ - (void )updater : (SPUUpdater *)updater didFindValidUpdate : (SUAppcastItem*)item {
540541 _manualCheck = NO ;
541542 NSString * channel = [[NSUserDefaults standardUserDefaults ] stringForKey: kUserDefaultsKey_ReleaseChannel ];
542543 XLOG_INFO (@" Did find app update on channel '%@ ' for version %@ " , channel, item.versionString );
543544}
544545
545- - (void )updaterDidNotFindUpdate : (SUUpdater *)updater {
546+ - (void )updaterDidNotFindUpdate : (SPUUpdater *)updater error : ( NSError *) error {
546547 NSString * channel = [[NSUserDefaults standardUserDefaults ] stringForKey: kUserDefaultsKey_ReleaseChannel ];
547548 XLOG_VERBOSE (@" App is up-to-date at version %@ on channel '%@ '" , [[NSBundle mainBundle ] objectForInfoDictionaryKey: @" CFBundleVersion" ], channel);
548549 if (_manualCheck) {
@@ -555,22 +556,23 @@ - (void)updaterDidNotFindUpdate:(SUUpdater*)updater {
555556 }
556557}
557558
558- - (void )updater : (SUUpdater *)updater didAbortWithError : (NSError *)error {
559+ - (void )updater : (SPUUpdater *)updater didAbortWithError : (NSError *)error {
559560 NSString * channel = [[NSUserDefaults standardUserDefaults ] stringForKey: kUserDefaultsKey_ReleaseChannel ];
560561 if (![error.domain isEqualToString: SUSparkleErrorDomain] || (error.code != SUNoUpdateError)) {
561562 XLOG_ERROR (@" App update on channel '%@ ' aborted: %@ " , channel, error);
562563 }
563564}
564565
565- - (void )updater : (SUUpdater *)updater willInstallUpdate : (SUAppcastItem*)item {
566+ - (void )updater : (SPUUpdater *)updater willInstallUpdate : (SUAppcastItem*)item {
566567 XLOG_INFO (@" Installing app update for version %@ " , item.versionString );
567568}
568569
569- - (void )updater : (SUUpdater *)updater willInstallUpdateOnQuit : (SUAppcastItem*)item immediateInstallationInvocation : ( NSInvocation *) invocation {
570+ - (BOOL )updater : (SPUUpdater *)updater willInstallUpdateOnQuit : (SUAppcastItem*)item immediateInstallationBlock : ( void (^)( void )) installationBlock {
570571 XLOG_INFO (@" Will install app update for version %@ on quit" , item.versionString );
571572 [self _showNotificationWithTitle: NSLocalizedString(@" Update Available" , nil )
572573 action: NULL
573574 message: NSLocalizedString(@" Relaunch GitUp to update to version %@ (%@ )." , nil ), item.displayVersionString, item.versionString];
575+ return NO ;
574576}
575577
576578#pragma mark - UNUserNotificationCenterDelegate
0 commit comments