mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
Fixed 244761
Added a delegate method: - (id <SUVersionComparison>)versionComparatorForHostBundle:(NSBundle *)hb; Override this to specify a custom SUVersionComparison implementor to be used.
This commit is contained in:
1 parent
88ab4b6f52
commit
aaa60d261d
2 files changed
+23
-7
No files matched your search
+18
-6
@@ -31,25 +31,37 @@
|
||||
[[SUUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:SULastCheckTimeKey];
|
||||
}
|
||||
|
||||
- (id <SUVersionComparison>)_versionComparator
|
||||
{
|
||||
id <SUVersionComparison> comparator = nil;
|
||||
|
||||
// Give the delegate a chance to provide a custom version comparator
|
||||
if ([delegate respondsToSelector:@selector(versionComparatorForHostBundle:)])
|
||||
comparator = [delegate versionComparatorForHostBundle:hostBundle];
|
||||
|
||||
// If we don't get a comparator from the delegate, use the default comparator
|
||||
if (!comparator)
|
||||
comparator = [SUStandardVersionComparator defaultComparator];
|
||||
|
||||
return comparator;
|
||||
}
|
||||
|
||||
- (BOOL)isItemNewer:(SUAppcastItem *)ui
|
||||
{
|
||||
return [[SUStandardVersionComparator defaultComparator] compareVersion:[hostBundle version]
|
||||
toVersion:[ui versionString]] == NSOrderedAscending;
|
||||
return [[self _versionComparator] compareVersion:[hostBundle version] toVersion:[ui versionString]] == NSOrderedAscending;
|
||||
}
|
||||
|
||||
- (BOOL)hostSupportsItem:(SUAppcastItem *)ui
|
||||
{
|
||||
if ([ui minimumSystemVersion] == nil || [[ui minimumSystemVersion] isEqualToString:@""]) { return YES; }
|
||||
return [[SUStandardVersionComparator defaultComparator] compareVersion:[ui minimumSystemVersion]
|
||||
toVersion:[NSWorkspace systemVersionString]] != NSOrderedDescending;
|
||||
return [[self _versionComparator] compareVersion:[ui minimumSystemVersion] toVersion:[NSWorkspace systemVersionString]] != NSOrderedDescending;
|
||||
}
|
||||
|
||||
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui
|
||||
{
|
||||
NSString *skippedVersion = [[SUUserDefaults standardUserDefaults] objectForKey:SUSkippedVersionKey];
|
||||
if (skippedVersion == nil) { return NO; }
|
||||
return [[SUStandardVersionComparator defaultComparator] compareVersion:[ui versionString]
|
||||
toVersion:skippedVersion] != NSOrderedDescending;
|
||||
return [[self _versionComparator] compareVersion:[ui versionString] toVersion:skippedVersion] != NSOrderedDescending;
|
||||
}
|
||||
|
||||
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui
|
||||
|
||||
+5
-1
@@ -10,6 +10,7 @@
|
||||
#define SUUPDATER_H
|
||||
|
||||
#import "SUUpdateAlert.h"
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
|
||||
@class SUUpdateDriver, SUAppcastItem, SUAppcast;
|
||||
@interface SUUpdater : NSObject {
|
||||
@@ -45,7 +46,6 @@
|
||||
- (void)updatePreferencesChanged;
|
||||
|
||||
- (BOOL)updateInProgress;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSObject (SUUpdaterDelegateInformalProtocol)
|
||||
@@ -81,6 +81,10 @@
|
||||
// Called immediately before relaunching.
|
||||
- (void)updaterWillRelaunchApplication;
|
||||
|
||||
// This method allows you to provide a custom version comparator.
|
||||
// If you don't implement this method or return nil, the standard version comparator will be used.
|
||||
- (id <SUVersionComparison>)versionComparatorForHostBundle:(NSBundle *)hb;
|
||||
|
||||
@end
|
||||
|
||||
// Define some minimum intervals to avoid DOS-like checking attacks. These are in seconds.
|
||||
|
||||
Reference in new issue
Block a user