Delegate can now control how version numbers are formatted/displayed to the user, so we can e.g. exclude build numbers or whatever makes sense for a particular application.

This commit is contained in:
Uli Kusterer committed 2009-12-08 19:02:10 +01:00
1 parent cee669c276
commit a453afa29a
5 files changed
+77 -2

No files matched your search

+5
View File
@@ -20,6 +20,11 @@
updateAlert = [[SUUpdateAlert alloc] initWithAppcastItem:updateItem host:host];
[updateAlert setDelegate:self];
id<SUVersionDisplay> versDisp = nil;
if ([[updater delegate] respondsToSelector:@selector(versionDisplayerForUpdater:)])
versDisp = [[updater delegate] versionDisplayerForUpdater: updater];
[updateAlert setVersionDisplayer: versDisp];
if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)])
[[updater delegate] updater:updater didFindValidUpdate:updateItem];
+5
View File
@@ -10,6 +10,8 @@
#define SUUPDATEALERT_H
#import "SUWindowController.h"
#import "SUVersionDisplayProtocol.h"
typedef enum
{
@@ -24,6 +26,7 @@ typedef enum
SUAppcastItem *updateItem;
SUHost *host;
id delegate;
id<SUVersionDisplay> versionDisplayer;
IBOutlet WebView *releaseNotesView;
IBOutlet NSTextField *description;
@@ -39,6 +42,8 @@ typedef enum
- (IBAction)skipThisVersion:sender;
- (IBAction)remindMeLater:sender;
- (void)setVersionDisplayer: (id<SUVersionDisplay>)disp;
@end
@interface NSObject (SUUpdateAlertDelegate)
+8 -1
View File
@@ -48,6 +48,11 @@
[super dealloc];
}
- (void)setVersionDisplayer: (id<SUVersionDisplay>)disp
{
versionDisplayer = disp;
}
- (void)endWithSelection:(SUUpdateAlertChoice)choice
{
[releaseNotesView stopLoading:self];
@@ -233,11 +238,13 @@
NSString *updateItemVersion = [updateItem displayVersionString];
NSString *hostVersion = [host displayVersion];
// Display more info if the version strings are the same; useful for betas.
if ([updateItemVersion isEqualToString:hostVersion])
if( !versionDisplayer && [updateItemVersion isEqualToString:hostVersion] )
{
updateItemVersion = [updateItemVersion stringByAppendingFormat:@" (%@)", [updateItem versionString]];
hostVersion = [hostVersion stringByAppendingFormat:@" (%@)", [host version]];
}
else
[versionDisplayer formatVersion: &updateItemVersion andVersion: &hostVersion];
return [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available--you have %@. Would you like to download it now?", nil), [host name], updateItemVersion, hostVersion];
}
+32 -1
View File
@@ -9,10 +9,27 @@
#ifndef SUUPDATER_H
#define SUUPDATER_H
// -----------------------------------------------------------------------------
// Headers:
// -----------------------------------------------------------------------------
#import "SUVersionComparisonProtocol.h"
#import "SUVersionDisplayProtocol.h"
// -----------------------------------------------------------------------------
// Forwards:
// -----------------------------------------------------------------------------
@class SUUpdateDriver, SUAppcastItem, SUHost, SUAppcast;
@interface SUUpdater : NSObject {
// -----------------------------------------------------------------------------
// SUUpdater:
// -----------------------------------------------------------------------------
@interface SUUpdater : NSObject
{
NSTimer *checkTimer;
SUUpdateDriver *driver;
@@ -73,6 +90,11 @@
@end
// -----------------------------------------------------------------------------
// SUUpdater Delegate:
// -----------------------------------------------------------------------------
@interface NSObject (SUUpdaterDelegateInformalProtocol)
// Use this to keep Sparkle from popping up e.g. while your setup assistant is showing:
@@ -119,11 +141,20 @@
// If you don't implement this method or return nil, the standard version comparator will be used.
- (id <SUVersionComparison>)versionComparatorForUpdater:(SUUpdater *)updater;
// 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 <SUVersionDisplay>)versionDisplayerForUpdater:(SUUpdater *)updater;
// Returns the path which is used to relaunch the client after the update is installed. By default, the path of the host bundle.
- (NSString *)pathToRelaunchForUpdater:(SUUpdater *)updater;
@end
// -----------------------------------------------------------------------------
// Constants:
// -----------------------------------------------------------------------------
// Define some minimum intervals to avoid DOS-like checking attacks. These are in seconds.
#ifdef DEBUG && 0
#define SU_MIN_CHECK_INTERVAL 60
+27
View File
@@ -0,0 +1,27 @@
//
// SUVersionDisplayProtocol.h
// EyeTV
//
// Created by Uli Kusterer on 08.12.09.
// Copyright 2009 Elgato Systems GmbH. All rights reserved.
//
#import <Cocoa/Cocoa.h>
/*!
@protocol
@abstract Implement this protocol to apply special formatting to the two
version numbers.
*/
@protocol SUVersionDisplay
/*!
@method
@abstract An abstract method to format two version strings.
@discussion You get both so you can display important distinguishing
information, but leave out unnecessary/confusing parts.
*/
-(void) formatVersion: (NSString**)inOutVersionA andVersion: (NSString**)inOutVersionB;
@end