From 80276f5bfba37487eda329287e8735c2f3ac1d90 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 4 Jan 2020 16:16:07 -0500 Subject: [PATCH] Query the appcast-unstable.xml feed based off the pref. --- Source/AppDelegate.h | 4 +++- Source/AppDelegate.m | 33 +++++++++++++++++++++++---------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/Source/AppDelegate.h b/Source/AppDelegate.h index 990107b..7f4a012 100644 --- a/Source/AppDelegate.h +++ b/Source/AppDelegate.h @@ -16,12 +16,14 @@ #import +#import + #import "BreakpointController.h" #import "DebuggerController.h" #import "LoggingController.h" #import "PreferencesController.h" -@interface AppDelegate : NSObject +@interface AppDelegate : NSObject { IBOutlet DebuggerController* debugger; IBOutlet LoggingController* loggingController_; diff --git a/Source/AppDelegate.m b/Source/AppDelegate.m index d7948ac..f059e2c 100644 --- a/Source/AppDelegate.m +++ b/Source/AppDelegate.m @@ -21,6 +21,8 @@ #import "FileAccessController.h" #import "PreferenceNames.h" +static NSString* const kAppcastUnstable = @"appcast-unstable.xml"; + @implementation AppDelegate { PreferencesController* _prefsController; } @@ -65,16 +67,7 @@ - (void)applicationDidFinishLaunching:(NSNotification*)notification { - // Record whether this user ever used the beta VersionCast feed. In the - // future, we will use this bit to query for unstable releases after the user - // has upgraded to a stable version. - NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; - - BOOL usesUnstable = [defaults boolForKey:kPrefUnstableVersionCast]; - NSURL* feedURL = [[SUUpdater sharedUpdater] feedURL]; - usesUnstable = usesUnstable || - [[feedURL absoluteString] rangeOfString:@"?unstable"].location != NSNotFound; - [defaults setBool:usesUnstable forKey:kPrefUnstableVersionCast]; + [[SUUpdater sharedUpdater] setDelegate:self]; #if USE_APP_SANDBOX [FileAccessController maybeShowFileAccessDialog]; @@ -161,4 +154,24 @@ } #endif // USE_APP_SANDBOX +//////////////////////////////////////////////////////////////////////////////// +#pragma mark SUUpdater Delegate + +- (nullable NSString*)feedURLStringForUpdater:(SUUpdater*)updater +{ + // Record whether this user ever used the beta appcast feed. + NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; + NSURL* feedURL = [NSURL URLWithString:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"SUFeedURL"]]; + + BOOL usesUnstable = [defaults boolForKey:kPrefUnstableVersionCast] || + [[feedURL absoluteString] hasSuffix:kAppcastUnstable]; + [defaults setBool:usesUnstable forKey:kPrefUnstableVersionCast]; + + if (!usesUnstable) + return nil; + + feedURL = [[feedURL URLByDeletingLastPathComponent] URLByAppendingPathComponent:kAppcastUnstable]; + return [feedURL absoluteString]; +} + @end -- 2.43.5