Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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.
  • Loading branch information...
commit a453afa29a88e12e5527e143e2b97f5aa6a47622 1 parent cee669c
Uli Kusterer authored
View
5 SUUIBasedUpdateDriver.m
@@ -20,6 +20,11 @@ - (void)didFindValidUpdate
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];
View
5 SUUpdateAlert.h
@@ -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)
View
9 SUUpdateAlert.m
@@ -48,6 +48,11 @@ - (void)dealloc
[super dealloc];
}
+- (void)setVersionDisplayer: (id<SUVersionDisplay>)disp
+{
+ versionDisplayer = disp;
+}
+
- (void)endWithSelection:(SUUpdateAlertChoice)choice
{
[releaseNotesView stopLoading:self];
@@ -233,11 +238,13 @@ - (NSString *)descriptionText
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];
}
View
33 SUUpdater.h
@@ -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
View
27 SUVersionDisplayProtocol.h
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.