Add sandbox compatible Sparkle.
This commit is contained in:
234 files changed
+2968
-419
No files matched your search
+43
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// SPUDownloadData.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 8/10/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
* A class for containing downloaded data along with some information about it.
|
||||
*/
|
||||
SU_EXPORT @interface SPUDownloadData : NSObject <NSSecureCoding>
|
||||
|
||||
- (instancetype)initWithData:(NSData *)data textEncodingName:(NSString * _Nullable)textEncodingName MIMEType:(NSString * _Nullable)MIMEType;
|
||||
|
||||
/*!
|
||||
* The raw data that was downloaded.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSData *data;
|
||||
|
||||
/*!
|
||||
* The IANA charset encoding name if available. Eg: "utf-8"
|
||||
*/
|
||||
@property (nonatomic, readonly, nullable, copy) NSString *textEncodingName;
|
||||
|
||||
/*!
|
||||
* The MIME type if available. Eg: "text/plain"
|
||||
*/
|
||||
@property (nonatomic, readonly, nullable, copy) NSString *MIMEType;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
//
|
||||
// SPUStandardUpdaterController.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 2/28/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Cocoa;
|
||||
#else
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SPUUpdater;
|
||||
@protocol SPUUserDriver, SPUStandardUserDriverProtocol, SPUUpdaterDelegate, SPUStandardUserDriverDelegate;
|
||||
|
||||
/*!
|
||||
A controller class that instantiates a SPUUpdater and allows binding UI to it.
|
||||
|
||||
This class can be instantiated in a nib or created using initWithUpdaterDelegate:userDriverDelegate:. The controller's updater targets the application's main bundle
|
||||
and uses Sparkle's standard user interface. Typically, this class is used by sticking it as a custom NSObject subclass in an Interface Builder nib (probably in MainMenu).
|
||||
|
||||
The controller creates an SPUUpdater instance and allows hooking up the check for updates action and menu item validation. It also allows hooking
|
||||
up the updater's and user driver's delegates.
|
||||
|
||||
This controller class may not be valuable to you if:
|
||||
* You want to control or defer the instantiation of an SPUUpdater, or don't want to be tied into a nib's instantiation, or don't want to use a nib
|
||||
* You want to target a bundle that's not the main bundle
|
||||
* You want to provide a custom user interface, or perhaps one that provides little-to-none
|
||||
* You don't want to use a convenience class that provides very little glue ;)
|
||||
|
||||
*/
|
||||
SU_EXPORT @interface SPUStandardUpdaterController : NSObject
|
||||
|
||||
/*!
|
||||
Interface builder outlet for the updater's delegate.
|
||||
|
||||
This property should only be set using Interface Builder by creating a connection using the outlet
|
||||
*/
|
||||
@property (nonatomic, weak, nullable) IBOutlet id<SPUUpdaterDelegate> updaterDelegate;
|
||||
|
||||
/*!
|
||||
Interface builder outlet for the user driver's delegate.
|
||||
|
||||
This property should only be set using Interface Builder by creating a connection using the outlet
|
||||
*/
|
||||
@property (nonatomic, weak, nullable) IBOutlet id<SPUStandardUserDriverDelegate> userDriverDelegate;
|
||||
|
||||
/*!
|
||||
Accessible property for the updater. Some properties on the updater can be binded via KVO
|
||||
|
||||
This is nil before being loaded from the nib.
|
||||
You may access this property after your application has finished launching, or after your window controller has finished loading.
|
||||
*/
|
||||
@property (nonatomic, readonly, nullable) SPUUpdater *updater;
|
||||
|
||||
/*!
|
||||
Accessible property for the updater's user driver.
|
||||
|
||||
This is nil before being loaded from the nib.
|
||||
You may access this property after your application has finished launching, or after your window controller has finished loading.
|
||||
*/
|
||||
@property (nonatomic, readonly, nullable) id <SPUStandardUserDriverProtocol> userDriver;
|
||||
|
||||
/*!
|
||||
Use initWithUpdaterDelegate:userDriverDelegate: instead.
|
||||
*/
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
/*!
|
||||
Create a new SPUStandardUpdaterController programmatically.
|
||||
*/
|
||||
- (instancetype)initWithUpdaterDelegate:(nullable id<SPUUpdaterDelegate>)updaterDelegate userDriverDelegate:(nullable id<SPUStandardUserDriverDelegate>)userDriverDelegate;
|
||||
|
||||
/*!
|
||||
Explicitly checks for updates and displays a progress dialog while doing so.
|
||||
|
||||
This method is meant for a main menu item.
|
||||
Connect any menu item to this action in Interface Builder,
|
||||
and Sparkle will check for updates and report back its findings verbosely
|
||||
when it is invoked.
|
||||
|
||||
This action checks updates by invoking -[SPUUpdater checkForUpdates]
|
||||
*/
|
||||
- (IBAction)checkForUpdates:(id)sender;
|
||||
|
||||
/*!
|
||||
Validates if the menu item for checkForUpdates: can be invoked or not
|
||||
|
||||
This validates the menu item by checking -[SPUStandardUserDriver canCheckForUpdates]
|
||||
*/
|
||||
- (BOOL)validateMenuItem:(NSMenuItem *)item;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// SPUStandardUserDriver.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 2/14/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Cocoa;
|
||||
#else
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SPUUserDriver.h>
|
||||
#import <Sparkle/SPUStandardUserDriverProtocol.h>
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol SPUStandardUserDriverDelegate;
|
||||
|
||||
/*!
|
||||
Sparkle's standard built-in user driver for updater interactions
|
||||
*/
|
||||
SU_EXPORT @interface SPUStandardUserDriver : NSObject <SPUUserDriver, SPUStandardUserDriverProtocol>
|
||||
|
||||
/*!
|
||||
Initializes a Sparkle's standard user driver for user update interactions
|
||||
|
||||
@param hostBundle The target bundle of the host that is being updated.
|
||||
@param delegate The delegate to this user driver. Pass nil if you don't want to provide one.
|
||||
*/
|
||||
- (instancetype)initWithHostBundle:(NSBundle *)hostBundle delegate:(nullable id<SPUStandardUserDriverDelegate>)delegate;
|
||||
|
||||
/*!
|
||||
* Enable or disable hideOnDeactivate for standard update window.
|
||||
*/
|
||||
@property (nonatomic) BOOL hideOnDeactivate;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// SPUStandardUserDriverDelegate.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 3/3/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
@protocol SUVersionDisplay;
|
||||
|
||||
/*!
|
||||
A protocol for Sparkle's standard user driver's delegate
|
||||
|
||||
This includes methods related to UI interactions
|
||||
*/
|
||||
SU_EXPORT @protocol SPUStandardUserDriverDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
|
||||
/*!
|
||||
Called before showing a modal alert window,
|
||||
to give the opportunity to hide attached windows that may get in the way.
|
||||
*/
|
||||
- (void)standardUserDriverWillShowModalAlert;
|
||||
|
||||
/*!
|
||||
Called after showing a modal alert window,
|
||||
to give the opportunity to hide attached windows that may get in the way.
|
||||
*/
|
||||
- (void)standardUserDriverDidShowModalAlert;
|
||||
|
||||
/*!
|
||||
Returns an object that formats version numbers for display to the user.
|
||||
If you don't implement this method or return \c nil,
|
||||
the standard version formatter will be used.
|
||||
*/
|
||||
- (_Nullable id <SUVersionDisplay>)standardUserDriverRequestsVersionDisplayer;
|
||||
|
||||
@end
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// SPUStandardUserDriverProtocol.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 3/5/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@protocol SPUStandardUserDriverDelegate;
|
||||
|
||||
/*!
|
||||
Protocol for Sparkle's standard built-in user driver for updater interactions.
|
||||
|
||||
Other user drivers may wish to implement this protocol.
|
||||
Note that this protocol does not adopt SUUserDriver because one may want to *only* export properties from this protocol.
|
||||
*/
|
||||
@protocol SPUStandardUserDriverProtocol <NSObject>
|
||||
|
||||
/*!
|
||||
Indicates whether or not an update is in progress as far as the user's perspective is concerned
|
||||
|
||||
A typical application may rely on this property for its check for updates menu item validation
|
||||
*/
|
||||
@property (nonatomic, readonly) BOOL canCheckForUpdates;
|
||||
|
||||
@end
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// SPUStatusCompletionResults.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 2/29/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SPUStatusCompletionResults_h
|
||||
#define SPUStatusCompletionResults_h
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
typedef NS_ENUM(NSUInteger, SPUUserInitiatedCheckStatus) {
|
||||
SPUUserInitiatedCheckDone,
|
||||
SPUUserInitiatedCheckCanceled
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSUInteger, SPUDownloadUpdateStatus) {
|
||||
SPUDownloadUpdateDone,
|
||||
SPUDownloadUpdateCanceled
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSUInteger, SPUInstallUpdateStatus) {
|
||||
SPUInstallUpdateNow,
|
||||
SPUInstallAndRelaunchUpdateNow,
|
||||
SPUDismissUpdateInstallation
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, SPUUpdateAlertChoice) {
|
||||
SPUInstallUpdateChoice,
|
||||
SPUInstallLaterChoice,
|
||||
SPUSkipThisVersionChoice
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, SPUInformationalUpdateAlertChoice) {
|
||||
SPUDismissInformationalNoticeChoice,
|
||||
SPUSkipThisInformationalVersionChoice
|
||||
};
|
||||
|
||||
#endif /* SPUStatusCompletionResults_h */
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// SPUUpdatePermissionRequest.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 8/14/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
This class represents information needed to make a permission request for checking updates.
|
||||
*/
|
||||
SU_EXPORT @interface SPUUpdatePermissionRequest : NSObject<NSSecureCoding>
|
||||
|
||||
/*!
|
||||
Initializes a new update permission request instance.
|
||||
|
||||
@param systemProfile The system profile information.
|
||||
*/
|
||||
- (instancetype)initWithSystemProfile:(NSArray<NSDictionary<NSString *, NSString *> *> *)systemProfile;
|
||||
|
||||
/*!
|
||||
A read-only property for the user's system profile.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSArray<NSDictionary<NSString *, NSString *> *> *systemProfile;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+209
@@ -0,0 +1,209 @@
|
||||
//
|
||||
// SPUUpdater.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 1/4/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import <Sparkle/SUExport.h>
|
||||
#import <Sparkle/SPUUserDriver.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SUAppcastItem, SUAppcast;
|
||||
|
||||
@protocol SPUUpdaterDelegate;
|
||||
|
||||
/*!
|
||||
The main API in Sparkle for controlling the update mechanism.
|
||||
|
||||
This class is used to configure the update parameters as well as manually
|
||||
and automatically schedule and control checks for updates.
|
||||
*/
|
||||
SU_EXPORT @interface SPUUpdater : NSObject
|
||||
|
||||
/*!
|
||||
Initializes a new SPUUpdater instance
|
||||
|
||||
This does not start the updater. To start it, see -[SPUUpdater startUpdater:]
|
||||
|
||||
Note that this is a normal initializer and doesn't implement the singleton pattern (i.e, instances aren't cached, so no surprises)
|
||||
This also means that updater instances can be deallocated, and that they will be torn down properly.
|
||||
|
||||
Related: See SPUStandardUpdaterController which wraps a SPUUpdater instance and is suitable for instantiating in nib files
|
||||
|
||||
@param hostBundle The bundle that should be targetted for updating. This must not be nil.
|
||||
@param applicationBundle The application bundle that should be relaunched and waited for termination. Usually this can be the same as hostBundle. This may differ when updating a plug-in or other non-application bundle.
|
||||
@param userDriver The user driver that Sparkle uses for user update interaction
|
||||
@param delegate The delegate for SPUUpdater. This may be nil.
|
||||
*/
|
||||
- (instancetype)initWithHostBundle:(NSBundle *)hostBundle applicationBundle:(NSBundle *)applicationBundle userDriver:(id <SPUUserDriver>)userDriver delegate:(id<SPUUpdaterDelegate> _Nullable)delegate;
|
||||
|
||||
/*!
|
||||
Starts the updater.
|
||||
|
||||
This method checks if Sparkle is configured properly. A valid feed URL should be set before this method is invoked.
|
||||
Other properties of this SPUUpdater instance can be set before this method is invoked as well, such as automatic update checks.
|
||||
|
||||
If the configuration is valid, this method may bring up a permission prompt (if needed) for checking if the user wants automatic update checking.
|
||||
This method then starts the regular update cycle if automatic update checks are enabled.
|
||||
|
||||
One of -checkForUpdates, -checkForUpdatesInBackground, or -checkForUpdateInformation can be invoked before starting the updater.
|
||||
This preschedules an update action before starting the updater. When the updater is started, the prescheduled action is immediately invoked.
|
||||
This may be useful for example if you want to check for updates right away without a permission prompt potentially showing.
|
||||
|
||||
This must be called on the main thread.
|
||||
|
||||
@param error The error that is populated if this method fails. Pass NULL if not interested in the error information.
|
||||
@return YES if the updater started otherwise NO with a populated error
|
||||
*/
|
||||
- (BOOL)startUpdater:(NSError * __autoreleasing *)error;
|
||||
|
||||
/*!
|
||||
Checks for updates, and displays progress while doing so.
|
||||
|
||||
This is meant for users initiating an update check.
|
||||
This may find a resumable update that has already been downloaded or has begun installing, or
|
||||
this may find a new update that can start to be downloaded if the user requests it.
|
||||
This will find updates that the user has opted into skipping.
|
||||
*/
|
||||
- (void)checkForUpdates;
|
||||
|
||||
/*!
|
||||
Checks for updates, but does not display any UI unless an update is found.
|
||||
|
||||
This is meant for programmatically initating a check for updates.
|
||||
That is, it will display no UI unless it finds an update, in which case it proceeds as usual.
|
||||
This will not find updates that the user has opted into skipping.
|
||||
|
||||
Note if there is no resumable update found, and automated updating is turned on,
|
||||
the update will be downloaded in the background without disrupting the user.
|
||||
*/
|
||||
- (void)checkForUpdatesInBackground;
|
||||
|
||||
/*!
|
||||
Begins a "probing" check for updates which will not actually offer to
|
||||
update to that version.
|
||||
|
||||
However, the delegate methods
|
||||
SPUUpdaterDelegate::updater:didFindValidUpdate: and
|
||||
SPUUpdaterDelegate::updaterDidNotFindUpdate: will be called,
|
||||
so you can use that information in your UI.
|
||||
|
||||
Updates that have been skipped by the user will not be found.
|
||||
*/
|
||||
- (void)checkForUpdateInformation;
|
||||
|
||||
/*!
|
||||
A property indicating whether or not to check for updates automatically.
|
||||
|
||||
Setting this property will persist in the host bundle's user defaults.
|
||||
The update schedule cycle will be reset in a short delay after the property's new value is set.
|
||||
This is to allow reverting this property without kicking off a schedule change immediately
|
||||
*/
|
||||
@property (nonatomic) BOOL automaticallyChecksForUpdates;
|
||||
|
||||
/*!
|
||||
A property indicating the current automatic update check interval.
|
||||
|
||||
Setting this property will persist in the host bundle's user defaults.
|
||||
The update schedule cycle will be reset in a short delay after the property's new value is set.
|
||||
This is to allow reverting this property without kicking off a schedule change immediately
|
||||
*/
|
||||
@property (nonatomic) NSTimeInterval updateCheckInterval;
|
||||
|
||||
/*!
|
||||
A property indicating whether or not updates can be automatically downloaded in the background.
|
||||
|
||||
Note that the developer can disallow automatic downloading of updates from being enabled.
|
||||
In this case, -automaticallyDownloadsUpdates will return NO regardless of how this property is set.
|
||||
|
||||
Setting this property will persist in the host bundle's user defaults.
|
||||
*/
|
||||
@property (nonatomic) BOOL automaticallyDownloadsUpdates;
|
||||
|
||||
/*!
|
||||
The URL of the appcast used to download update information.
|
||||
|
||||
If the updater's delegate implements -[SPUUpdaterDelegate feedURLStringForUpdater:], this will return that feed URL.
|
||||
Otherwise if the feed URL has been set before, the feed URL returned will be retrieved from the host bundle's user defaults.
|
||||
Otherwise the feed URL in the host bundle's Info.plist will be returned.
|
||||
If no feed URL can be retrieved, this will raise an exception.
|
||||
|
||||
This property must be called on the main thread.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSURL *feedURL;
|
||||
|
||||
/*!
|
||||
Set the URL of the appcast used to download update information. Using this method is discouraged.
|
||||
|
||||
Setting this property will persist in the host bundle's user defaults.
|
||||
To avoid this, you should consider instead implementing
|
||||
-[SPUUpdaterDelegate feedURLStringForUpdater:] or -[SPUUpdaterDelegate feedParametersForUpdater:sendingSystemProfile:]
|
||||
|
||||
Passing nil will remove any feed URL that has been set in the host bundle's user defaults.
|
||||
|
||||
This method must be called on the main thread.
|
||||
*/
|
||||
- (void)setFeedURL:(NSURL * _Nullable)feedURL;
|
||||
|
||||
/*!
|
||||
The host bundle that is being updated.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSBundle *hostBundle;
|
||||
|
||||
/*!
|
||||
The bundle this class (SPUUpdater) is loaded into
|
||||
*/
|
||||
@property (nonatomic, readonly) NSBundle *sparkleBundle;
|
||||
|
||||
/*!
|
||||
* The user agent used when checking for updates.
|
||||
*
|
||||
* The default implementation can be overrided.
|
||||
*/
|
||||
@property (nonatomic, copy) NSString *userAgentString;
|
||||
|
||||
/*!
|
||||
The HTTP headers used when checking for updates.
|
||||
|
||||
The keys of this dictionary are HTTP header fields (NSString) and values are corresponding values (NSString)
|
||||
*/
|
||||
#if __has_feature(objc_generics)
|
||||
@property (nonatomic, copy, nullable) NSDictionary<NSString *, NSString *> *httpHeaders;
|
||||
#else
|
||||
@property (nonatomic, copy, nullable) NSDictionary *httpHeaders;
|
||||
#endif
|
||||
|
||||
/*!
|
||||
A property indicating whether or not the user's system profile information is sent when checking for updates.
|
||||
|
||||
Setting this property will persist in the host bundle's user defaults.
|
||||
*/
|
||||
@property (nonatomic) BOOL sendsSystemProfile;
|
||||
|
||||
/*!
|
||||
Returns the date of last update check.
|
||||
|
||||
\returns \c nil if no check has been performed.
|
||||
*/
|
||||
@property (nonatomic, readonly, copy, nullable) NSDate *lastUpdateCheckDate;
|
||||
|
||||
/*!
|
||||
Appropriately schedules or cancels the update checking timer according to
|
||||
the preferences for time interval and automatic checks.
|
||||
|
||||
This call does not change the date of the next check,
|
||||
but only the internal timer.
|
||||
*/
|
||||
- (void)resetUpdateCycle;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+305
@@ -0,0 +1,305 @@
|
||||
//
|
||||
// SPUUpdaterDelegate.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 8/12/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
@protocol SUVersionComparison;
|
||||
@class SPUUpdater, SUAppcast, SUAppcastItem;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// SUUpdater Notifications for events that might be interesting to more than just the delegate
|
||||
// The updater will be the notification object
|
||||
// -----------------------------------------------------------------------------
|
||||
SU_EXPORT extern NSString *const SUUpdaterDidFinishLoadingAppCastNotification;
|
||||
SU_EXPORT extern NSString *const SUUpdaterDidFindValidUpdateNotification;
|
||||
SU_EXPORT extern NSString *const SUUpdaterDidNotFindUpdateNotification;
|
||||
SU_EXPORT extern NSString *const SUUpdaterWillRestartNotification;
|
||||
#define SUUpdaterWillRelaunchApplicationNotification SUUpdaterWillRestartNotification;
|
||||
#define SUUpdaterWillInstallUpdateNotification SUUpdaterWillRestartNotification;
|
||||
|
||||
// Key for the SUAppcastItem object in the SUUpdaterDidFindValidUpdateNotification userInfo
|
||||
SU_EXPORT extern NSString *const SUUpdaterAppcastItemNotificationKey;
|
||||
// Key for the SUAppcast object in the SUUpdaterDidFinishLoadingAppCastNotification userInfo
|
||||
SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// SPUUpdater Delegate:
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
typedef NS_ENUM(NSInteger, SPUUpdateCheck)
|
||||
{
|
||||
SPUUpdateCheckUserInitiated = 0,
|
||||
SPUUpdateCheckBackgroundScheduled = 1
|
||||
};
|
||||
|
||||
/*!
|
||||
Provides methods to control the behavior of an SPUUpdater object.
|
||||
*/
|
||||
@protocol SPUUpdaterDelegate <NSObject>
|
||||
@optional
|
||||
|
||||
/*!
|
||||
Called when a background update will be scheduled after a delay.
|
||||
|
||||
Automatic update checks need to be enabled for this to trigger.
|
||||
|
||||
\param delay The delay until the next scheduled update will occur.
|
||||
|
||||
\param updater The updater instance.
|
||||
*/
|
||||
- (void)updater:(SPUUpdater *)updater willScheduleUpdateCheckAfterDelay:(NSTimeInterval)delay;
|
||||
|
||||
/*!
|
||||
Called when no updates will be scheduled in the future.
|
||||
|
||||
This may later change if automatic update checks become enabled.
|
||||
|
||||
\param updater The updater instance.
|
||||
*/
|
||||
- (void)updaterWillIdleSchedulingUpdates:(SPUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Returns whether to allow Sparkle to pop up.
|
||||
|
||||
For example, this may be used to prevent Sparkle from interrupting a setup assistant.
|
||||
Alternatively, you may want to consider starting the updater after eg: the setup assistant finishes
|
||||
|
||||
\param updater The updater instance.
|
||||
*/
|
||||
- (BOOL)updaterMayCheckForUpdates:(SPUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Returns additional parameters to append to the appcast URL's query string.
|
||||
|
||||
This is potentially based on whether or not Sparkle will also be sending along the system profile.
|
||||
|
||||
\param updater The updater instance.
|
||||
\param sendingProfile Whether the system profile will also be sent.
|
||||
|
||||
\return An array of dictionaries with keys: "key", "value", "displayKey", "displayValue", the latter two being specifically for display to the user.
|
||||
*/
|
||||
#if __has_feature(objc_generics)
|
||||
- (NSArray<NSDictionary<NSString *, NSString *> *> *)feedParametersForUpdater:(SPUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile;
|
||||
#else
|
||||
- (NSArray *)feedParametersForUpdater:(SPUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile;
|
||||
#endif
|
||||
|
||||
/*!
|
||||
Returns a custom appcast URL.
|
||||
|
||||
Override this to dynamically specify the entire URL.
|
||||
Alternatively you may want to consider adding a feed parameter using -feedParametersForUpdater:sendingSystemProfile:
|
||||
and having the server which appcast to serve.
|
||||
|
||||
\param updater The updater instance.
|
||||
*/
|
||||
- (nullable NSString *)feedURLStringForUpdater:(SPUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Returns whether Sparkle should prompt the user about automatic update checks.
|
||||
|
||||
Use this to override the default behavior.
|
||||
|
||||
\param updater The updater instance.
|
||||
*/
|
||||
- (BOOL)updaterShouldPromptForPermissionToCheckForUpdates:(SPUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called after Sparkle has downloaded the appcast from the remote server.
|
||||
|
||||
Implement this if you want to do some special handling with the appcast once it finishes loading.
|
||||
|
||||
\param updater The updater instance.
|
||||
\param appcast The appcast that was downloaded from the remote server.
|
||||
*/
|
||||
- (void)updater:(SPUUpdater *)updater didFinishLoadingAppcast:(SUAppcast *)appcast;
|
||||
|
||||
/*!
|
||||
Returns the item in the appcast corresponding to the update that should be installed.
|
||||
|
||||
If you're using special logic or extensions in your appcast,
|
||||
implement this to use your own logic for finding a valid update, if any,
|
||||
in the given appcast.
|
||||
|
||||
\param appcast The appcast that was downloaded from the remote server.
|
||||
\param updater The updater instance.
|
||||
\return The best valid appcast item, or nil if you don't want to be delegated this task.
|
||||
*/
|
||||
- (nullable SUAppcastItem *)bestValidUpdateInAppcast:(SUAppcast *)appcast forUpdater:(SPUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called when a valid update is found by the update driver.
|
||||
|
||||
\param updater The updater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
*/
|
||||
- (void)updater:(SPUUpdater *)updater didFindValidUpdate:(SUAppcastItem *)item;
|
||||
|
||||
/*!
|
||||
Called when a valid update is not found.
|
||||
|
||||
\param updater The updater instance.
|
||||
*/
|
||||
- (void)updaterDidNotFindUpdate:(SPUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Returns whether the release notes (if available) should be downloaded after an update is found and shown.
|
||||
|
||||
This is specifically for the releaseNotesLink element in the appcast.
|
||||
|
||||
\param updater The updater instance.
|
||||
|
||||
\return \c YES to download and show the release notes if available, otherwise NO. The default behavior is YES.
|
||||
*/
|
||||
- (BOOL)updaterShouldDownloadReleaseNotes:(SPUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called immediately before downloading the specified update.
|
||||
|
||||
\param updater The updater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be downloaded.
|
||||
\param request The mutable URL request that will be used to download the update.
|
||||
*/
|
||||
- (void)updater:(SPUUpdater *)updater willDownloadUpdate:(SUAppcastItem *)item withRequest:(NSMutableURLRequest *)request;
|
||||
|
||||
/*!
|
||||
Called after the specified update failed to download.
|
||||
|
||||
\param updater The updater instance.
|
||||
\param item The appcast item corresponding to the update that failed to download.
|
||||
\param error The error generated by the failed download.
|
||||
*/
|
||||
- (void)updater:(SPUUpdater *)updater failedToDownloadUpdate:(SUAppcastItem *)item error:(NSError *)error;
|
||||
|
||||
/*!
|
||||
Called when the user clicks the cancel button while and update is being downloaded.
|
||||
|
||||
\param updater The updater instance.
|
||||
*/
|
||||
- (void)userDidCancelDownload:(SPUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called immediately before installing the specified update.
|
||||
|
||||
\param updater The updater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
*/
|
||||
- (void)updater:(SPUUpdater *)updater willInstallUpdate:(SUAppcastItem *)item;
|
||||
|
||||
/*!
|
||||
Returns whether the relaunch should be delayed in order to perform other tasks.
|
||||
|
||||
This is not called if the user didn't relaunch on the previous update,
|
||||
in that case it will immediately restart.
|
||||
|
||||
This may also not be called if the application is not going to relaunch after it terminates.
|
||||
|
||||
\param updater The updater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
\param installHandler The install handler that must be completed before continuing with the relaunch.
|
||||
|
||||
\return \c YES to delay the relaunch until \p installHandler is invoked.
|
||||
*/
|
||||
- (BOOL)updater:(SPUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)item untilInvokingBlock:(void (^)(void))installHandler;
|
||||
|
||||
/*!
|
||||
Returns whether the application should be relaunched at all.
|
||||
|
||||
Some apps \b cannot be relaunched under certain circumstances.
|
||||
This method can be used to explicitly prevent a relaunch.
|
||||
|
||||
\param updater The updater instance.
|
||||
\return YES if the updater should be relaunched, otherwise NO if it shouldn't.
|
||||
*/
|
||||
- (BOOL)updaterShouldRelaunchApplication:(SPUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called immediately before relaunching.
|
||||
|
||||
\param updater The updater instance.
|
||||
*/
|
||||
- (void)updaterWillRelaunchApplication:(SPUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Returns an object that compares version numbers to determine their arithmetic relation to each other.
|
||||
|
||||
This method allows you to provide a custom version comparator.
|
||||
If you don't implement this method or return \c nil,
|
||||
the standard version comparator will be used. Note that the
|
||||
standard version comparator may be used during installation for preventing
|
||||
a downgrade, even if you provide a custom comparator here.
|
||||
|
||||
\sa SUStandardVersionComparator
|
||||
|
||||
\param updater The updater instance.
|
||||
\return The custom version comparator or nil if you don't want to be delegated this task.
|
||||
*/
|
||||
- (nullable id<SUVersionComparison>)versionComparatorForUpdater:(SPUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Returns whether or not the updater should allow interaction from the installer
|
||||
|
||||
Use this to override the default behavior which is to allow interaction with the installer.
|
||||
|
||||
If interaction is allowed, then an authorization prompt may show up to the user if they do
|
||||
not curently have sufficient privileges to perform the installation of the new update.
|
||||
The installer may also show UI and progress when interaction is allowed.
|
||||
|
||||
On the other hand, if interaction is not allowed, then an installation may fail if the user does not
|
||||
have sufficient privileges to perform the installation. In this case, the feed and update may not even be downloaded.
|
||||
|
||||
Note this has no effect if the update has already been downloaded in the background silently and ready to be resumed.
|
||||
|
||||
\param updater The updater instance.
|
||||
\param updateCheck The type of update check being performed.
|
||||
*/
|
||||
- (BOOL)updater:(SPUUpdater *)updater shouldAllowInstallerInteractionForUpdateCheck:(SPUUpdateCheck)updateCheck;
|
||||
|
||||
/*!
|
||||
Returns the decryption password (if any) which is used to extract the update archive DMG.
|
||||
|
||||
Return nil if no password should be used.
|
||||
|
||||
\param updater The updater instance.
|
||||
\return The password used for decrypting the archive, or nil if no password should be used.
|
||||
*/
|
||||
- (nullable NSString *)decryptionPasswordForUpdater:(SPUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called when an update is scheduled to be silently installed on quit after downloading the update automatically.
|
||||
|
||||
\param updater The updater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
\param immediateInstallHandler The install handler to immediately install the update. No UI interaction will be shown and the application will be relaunched after installation.
|
||||
\return Return YES if the delegate will handle installing the update or NO if the updater should be given responsibility.
|
||||
|
||||
If the updater is given responsibility, it can later remind the user an update is available if they have not terminated the application for a long time.
|
||||
Also if the updater is given responsibility and the update item is marked critical, the new update will be presented to the user immediately after.
|
||||
Even if the immediateInstallHandler is not invoked, the installer will attempt to install the update on termination.
|
||||
*/
|
||||
- (BOOL)updater:(SPUUpdater *)updater willInstallUpdateOnQuit:(SUAppcastItem *)item immediateInstallationBlock:(void (^)(void))immediateInstallHandler;
|
||||
|
||||
/*!
|
||||
Called after an update is aborted due to an error.
|
||||
|
||||
\param updater The updater instance.
|
||||
\param error The error that caused the abort
|
||||
*/
|
||||
- (void)updater:(SPUUpdater *)updater didAbortWithError:(NSError *)error;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
//
|
||||
// SPUUpdaterSettings.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 3/27/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
This class can be used for reading certain updater settings.
|
||||
|
||||
It retrieves the settings by first looking into the host's user defaults.
|
||||
If the setting is not found in there, then the host's Info.plist file is looked at.
|
||||
*/
|
||||
SU_EXPORT @interface SPUUpdaterSettings : NSObject
|
||||
|
||||
- (instancetype)initWithHostBundle:(NSBundle *)hostBundle;
|
||||
|
||||
/*!
|
||||
* Indicates whether or not automatic update checks are enabled.
|
||||
*/
|
||||
@property (readonly, nonatomic) BOOL automaticallyChecksForUpdates;
|
||||
|
||||
/*!
|
||||
* The regular update check interval.
|
||||
*/
|
||||
@property (readonly, nonatomic) NSTimeInterval updateCheckInterval;
|
||||
|
||||
/*!
|
||||
* Indicates whether or not automatically downloading updates is allowed to be turned on by the user.
|
||||
*/
|
||||
@property (readonly, nonatomic) BOOL allowsAutomaticUpdates;
|
||||
|
||||
/*!
|
||||
* Indicates whether or not automatically downloading updates is enabled by the user or developer.
|
||||
*
|
||||
* Note this does not indicate whether or not automatic downloading of updates is allowable.
|
||||
* See `-allowsAutomaticUpdates` property for that.
|
||||
*/
|
||||
@property (readonly, nonatomic) BOOL automaticallyDownloadsUpdates;
|
||||
|
||||
/*!
|
||||
* Indicates whether or not anonymous system profile information is sent when checking for updates.
|
||||
*/
|
||||
@property (readonly, nonatomic) BOOL sendsSystemProfile;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+334
@@ -0,0 +1,334 @@
|
||||
//
|
||||
// SPUUserDriver.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 2/14/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SPUStatusCompletionResults.h>
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SPUUpdatePermissionRequest, SUUpdatePermissionResponse, SUAppcastItem, SPUDownloadData;
|
||||
|
||||
/*!
|
||||
The API in Sparkle for controlling the user interaction.
|
||||
|
||||
This protocol is used for implementing a user interface for the Sparkle updater. Sparkle's internal drivers tell
|
||||
an object that implements this protocol what actions to take and show to the user.
|
||||
|
||||
Every method in this protocol is required (i.e, not optional) and has a void return type and can optionally take a single parameter block, which waits for
|
||||
a response back from the user driver. Note that every parameter block, or reply, *must* be responded to eventually -
|
||||
that is, none can be ignored. Furthermore, they can only be replied to *once* - a reply or completion block should be considered
|
||||
invalidated after it's once used. The faster a reply can be made, the more Sparkle may be able to idle, and so the better.
|
||||
Lastly, every method in this protocol can be called from any thread. Thus, an implementor may choose to always
|
||||
dispatch asynchronously to the main thread. However, an implementor should also avoid unnecessary nested asynchronous dispatches.
|
||||
|
||||
An implementor of this protocol should act defensively. For example, it may be possible for an action that says to
|
||||
invalidate or dismiss something to be called multiple times in succession, and the implementor may choose to ignore further requests.
|
||||
|
||||
Note: Once upon a time, when first developing the user driver API, I had the user driver exist in a separate process from the rest of the framework.
|
||||
If you're familiar with how the higher level XPC APIs work, this explains why some of the decisions above were made
|
||||
(reply block executed on any thread, reply block replied only once, single reply block, void return types, idleness, no optional methods, ...)
|
||||
This is somewhat of an artifact (maybe?) now, but I think most of these set of restrictions still enforces a well designed API.
|
||||
*/
|
||||
SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
|
||||
/*!
|
||||
* Show that an update can be checked by the user or not
|
||||
*
|
||||
* A client may choose to update the interface letting the user know if they can check for updates.
|
||||
* For example, this can be used for menu item validation on the "Check for Updates" action.
|
||||
*
|
||||
* This can be called from any thread.
|
||||
*/
|
||||
- (void)showCanCheckForUpdates:(BOOL)canCheckForUpdates;
|
||||
|
||||
/*!
|
||||
* Show an updater permission request to the user
|
||||
*
|
||||
* Ask the user for their permission regarding update checks.
|
||||
* This is typically only called once per app installation.
|
||||
*
|
||||
* @param request The update permission request.
|
||||
* @param reply A reply with a update permission response.
|
||||
*
|
||||
* This can be called from any thread
|
||||
*/
|
||||
- (void)showUpdatePermissionRequest:(SPUUpdatePermissionRequest *)request reply:(void (^)(SUUpdatePermissionResponse *))reply;
|
||||
|
||||
/*!
|
||||
* Show the user initating an update check
|
||||
*
|
||||
* Respond to the user initiating an update check. Sparkle uses this to show the user a window with an indeterminate progress bar.
|
||||
*
|
||||
* @param updateCheckStatusCompletion A reply indicating whether the initiated update check is done or canceled.
|
||||
* Attempts to canceling can be made before -dismissUserInitiatedUpdateCheck is invoked. Replying with SPUUserInitiatedCheckDone
|
||||
* on the other hand should not be done until -dismissUserInitiatedUpdateCheck is invoked.
|
||||
*
|
||||
* This can be called from any thread
|
||||
*/
|
||||
- (void)showUserInitiatedUpdateCheckWithCompletion:(void (^)(SPUUserInitiatedCheckStatus))updateCheckStatusCompletion;
|
||||
|
||||
/*!
|
||||
* Dismiss the user initiated update check from the user
|
||||
*
|
||||
* Dismiss whatever was started in -showUserInitiatedUpdateCheckWithCompletion:
|
||||
* This is an appropriate time to reply with SPUUserInitiatedCheckDone if not having done so already
|
||||
*
|
||||
* This can be called from any thread
|
||||
*/
|
||||
- (void)dismissUserInitiatedUpdateCheck;
|
||||
|
||||
/*!
|
||||
* Show the user a new update is found and can be downloaded and installed
|
||||
*
|
||||
* Let the user know a new update is found and ask them what they want to do.
|
||||
*
|
||||
* @param appcastItem The Appcast Item containing information that reflects the new update
|
||||
*
|
||||
* @param userInitiated A flag indicating whether or not a user initiated this update check
|
||||
*
|
||||
* @param reply
|
||||
* A reply of SPUInstallUpdateChoice begins downloading and installing the new update.
|
||||
*
|
||||
* A reply of SPUInstallLaterChoice reminds the user later of the update, which can act as a "do nothing" option.
|
||||
*
|
||||
* A reply of SPUSkipThisVersionChoice skips this particular version and won't bother the user again,
|
||||
* unless they initiate an update check themselves.
|
||||
*
|
||||
* This can be called from any thread
|
||||
*/
|
||||
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated reply:(void (^)(SPUUpdateAlertChoice))reply;
|
||||
|
||||
/*!
|
||||
* Show the user a new update has been downloaded and can be installed
|
||||
*
|
||||
* This method behaves just like -showUpdateFoundWithAppcastItem:reply: except the update has already been downloaded.
|
||||
*/
|
||||
- (void)showDownloadedUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated reply:(void (^)(SPUUpdateAlertChoice))reply;
|
||||
|
||||
/*!
|
||||
* Show the user an update that has started installing can be resumed and installed immediately
|
||||
*
|
||||
* Let the user know an update that has already been downloaded and started installing can be resumed.
|
||||
* Note at this point the update cannot be canceled.
|
||||
*
|
||||
* @param appcastItem The Appcast Item containing information that reflects the new update
|
||||
*
|
||||
* @param userInitiated A flag indicating whether or not a user initiated this update check
|
||||
*
|
||||
* @param reply
|
||||
* A reply of SPUInstallAndRelaunchUpdateNow installs the update immediately and relaunches the new update.
|
||||
* Note: the application is not relaunched if it was not running before installing the update.
|
||||
* A reply of SPUInstallUpdateNow installs the update immediately but does not relaunch the new update.
|
||||
* A reply of SPUDismissUpdateInstallation dismisses the update installation. Note the update will attempt to finish installation
|
||||
* after the application terminates.
|
||||
*
|
||||
* This can be called from any thread
|
||||
*/
|
||||
- (void)showResumableUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated reply:(void (^)(SPUInstallUpdateStatus))reply;
|
||||
|
||||
/*!
|
||||
* Show the user a new informational only update has been found
|
||||
*
|
||||
* Let the user know a new informational update is found and ask them what they want to do.
|
||||
*
|
||||
* @param appcastItem The Appcast Item containing information that reflects the new update.
|
||||
* The infoURL property for the appcastItem may be of interest.
|
||||
*
|
||||
* @param userInitiated A flag indicating whether or not a user initiated this update check
|
||||
*
|
||||
* @param reply
|
||||
* A reply of SPUDismissInformationalNoticeChoice dismisses this notice.
|
||||
* An implementor may decide to invoke another action before dismissing the notice.
|
||||
*
|
||||
* A reply of SPUSkipThisInformationalVersionChoice skips this particular version and won't bother the user again,
|
||||
* unless they initiate an update check themselves.
|
||||
*
|
||||
* This can be called from any thread
|
||||
*/
|
||||
- (void)showInformationalUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem userInitiated:(BOOL)userInitiated reply:(void (^)(SPUInformationalUpdateAlertChoice))reply;
|
||||
|
||||
/*!
|
||||
* Show the user the release notes for the new update
|
||||
*
|
||||
* Display the release notes to the user. This will be called after showing the new update.
|
||||
* This is only applicable if the release notes are linked from the appcast, and are not directly embedded inside of the appcast file.
|
||||
* That is, this may be invoked if the releaseNotesURL from the appcast item is non-nil.
|
||||
*
|
||||
* @param downloadData The data for the release notes that was downloaded from the new update's appcast.
|
||||
*
|
||||
* This can be called from any thread
|
||||
*/
|
||||
- (void)showUpdateReleaseNotesWithDownloadData:(SPUDownloadData *)downloadData;
|
||||
|
||||
/*!
|
||||
* Show the user that the new update's release notes could not be downloaded
|
||||
*
|
||||
* This will be called after showing the new update.
|
||||
* This is only applicable if the release notes are linked from the appcast, and are not directly embedded inside of the appcast file.
|
||||
* That is, this may be invoked if the releaseNotesURL from the appcast item is non-nil.
|
||||
*
|
||||
* @param error The error associated with why the new update's release notes could not be downloaded.
|
||||
*
|
||||
* This can be called from any thread
|
||||
*/
|
||||
- (void)showUpdateReleaseNotesFailedToDownloadWithError:(NSError *)error;
|
||||
|
||||
/*!
|
||||
* Show the user a new update was not found
|
||||
*
|
||||
* Let the user know a new update was not found after they tried initiating an update check.
|
||||
*
|
||||
* @param acknowledgement Acknowledge to the updater that no update found was shown.
|
||||
*
|
||||
* This can be called from any thread
|
||||
*/
|
||||
- (void)showUpdateNotFoundWithAcknowledgement:(void (^)(void))acknowledgement;
|
||||
|
||||
/*!
|
||||
* Show the user an update error occurred
|
||||
*
|
||||
* Let the user know that the updater failed with an error. This will not be invoked without the user having been
|
||||
* aware that an update was in progress.
|
||||
*
|
||||
* @param acknowledgement Acknowledge to the updater that the error was shown.
|
||||
*
|
||||
* This can be called from any thread
|
||||
*/
|
||||
- (void)showUpdaterError:(NSError *)error acknowledgement:(void (^)(void))acknowledgement;
|
||||
|
||||
/*!
|
||||
* Show the user that downloading the new update initiated
|
||||
*
|
||||
* Let the user know that downloading the new update started.
|
||||
*
|
||||
* @param downloadUpdateStatusCompletion A reply of SPUDownloadUpdateCanceled can be used to cancel
|
||||
* the download at any point before -showDownloadDidStartExtractingUpdate is invoked.
|
||||
* A reply of SPUDownloadUpdateDone signifies that the download is done, which should not be invoked until
|
||||
* -showDownloadDidStartExtractingUpdate
|
||||
*
|
||||
* This can be called from any thread
|
||||
*/
|
||||
- (void)showDownloadInitiatedWithCompletion:(void (^)(SPUDownloadUpdateStatus))downloadUpdateStatusCompletion;
|
||||
|
||||
/*!
|
||||
* Show the user the content length of the new update that will be downloaded
|
||||
*
|
||||
* @param expectedContentLength The expected content length of the new update being downloaded.
|
||||
* An implementor should be able to handle if this value is invalid (more or less than actual content length downloaded).
|
||||
* Additionally, this method may be called more than once for the same download in rare scenarios.
|
||||
*
|
||||
* This can be called from any thread
|
||||
*/
|
||||
- (void)showDownloadDidReceiveExpectedContentLength:(uint64_t)expectedContentLength;
|
||||
|
||||
/*!
|
||||
* Show the user that the update download received more data
|
||||
*
|
||||
* This may be an appropriate time to advance a visible progress indicator of the download
|
||||
* @param length The length of the data that was just downloaded
|
||||
*
|
||||
* This can be called from any thread
|
||||
*/
|
||||
- (void)showDownloadDidReceiveDataOfLength:(uint64_t)length;
|
||||
|
||||
/*!
|
||||
* Show the user that the update finished downloading and started extracting
|
||||
*
|
||||
* This is an appropriate time to reply with SPUDownloadUpdateDone if not done so already
|
||||
* Sparkle uses this to show an indeterminate progress bar.
|
||||
*
|
||||
* Note that an update can resume at this point after having been downloaded before,
|
||||
* so this may be called without any of the download callbacks being invoked prior.
|
||||
*
|
||||
* This can be called from any thread
|
||||
*/
|
||||
- (void)showDownloadDidStartExtractingUpdate;
|
||||
|
||||
/*!
|
||||
* Show the user that the update is extracting with progress
|
||||
*
|
||||
* Let the user know how far along the update extraction is.
|
||||
*
|
||||
* @param progress The progress of the extraction from a 0.0 to 1.0 scale
|
||||
*
|
||||
* This can be called from any thread
|
||||
*/
|
||||
- (void)showExtractionReceivedProgress:(double)progress;
|
||||
|
||||
/*!
|
||||
* Show the user that the update is ready to install
|
||||
*
|
||||
* Let the user know that the update is ready and ask them whether they want to install or not.
|
||||
* Note if the target application is already terminated and an update can be performed silently, this method may not be invoked.
|
||||
*
|
||||
* @param installUpdateHandler
|
||||
* A reply of SPUInstallAndRelaunchUpdateNow installs the update immediately and relaunches the new update.
|
||||
* Note: the application is not relaunched if it was not running before installing the update.
|
||||
* A reply of SPUInstallUpdateNow installes the update immediately but does not relaunch the new update.
|
||||
* A reply of SPUDismissUpdateInstallation dismisses the update installation. Note the update may still be installed after
|
||||
* the application terminates, however there is not a strong guarantee that this will happen.
|
||||
*
|
||||
* This can be called from any thread
|
||||
*/
|
||||
- (void)showReadyToInstallAndRelaunch:(void (^)(SPUInstallUpdateStatus))installUpdateHandler;
|
||||
|
||||
/*!
|
||||
* Show the user that the update is installing
|
||||
*
|
||||
* Let the user know that the update is currently installing. Sparkle uses this to show an indeterminate progress bar.
|
||||
*
|
||||
* This can be called from any thread
|
||||
*/
|
||||
- (void)showInstallingUpdate;
|
||||
|
||||
/*!
|
||||
* Show or dismiss progress while a termination signal is being sent to the application
|
||||
*
|
||||
* Terminating and relaunching the application (if requested to be relaunched) may happen quickly,
|
||||
* or it may take some time to perform the final installation, or the termination signal can be canceled or delayed by the application or user.
|
||||
*
|
||||
* It is up to the implementor whether or not to decide to continue showing installation progress
|
||||
* or dismissing UI that won't remain obscuring other parts of the user interface.
|
||||
*
|
||||
* This can be called from any thread
|
||||
*/
|
||||
- (void)showSendingTerminationSignal;
|
||||
|
||||
/*!
|
||||
* Show the user that the update installation finished
|
||||
*
|
||||
* Let the user know that the update finished installing.
|
||||
* This will only be invoked if the updater process is still alive, which is typically not the case if
|
||||
* the updater's lifetime is tied to the application it is updating.
|
||||
*
|
||||
* @param acknowledgement Acknowledge to the updater that the installation finish was shown.
|
||||
*
|
||||
* This can be called from any thread
|
||||
*/
|
||||
- (void)showUpdateInstallationDidFinishWithAcknowledgement:(void (^)(void))acknowledgement;
|
||||
|
||||
/*!
|
||||
* Dismiss the current update installation
|
||||
*
|
||||
* Stop and tear down everything. Reply to all outstanding reply/completion blocks.
|
||||
* Dismiss all update windows, alerts, progress, etc from the user.
|
||||
* Basically, stop everything that could have been started. Sparkle may invoke this when aborting or finishing an update.
|
||||
*
|
||||
* This can be called from any thread
|
||||
*/
|
||||
- (void)dismissUpdateInstallation;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// SUUserDriverCoreComponent.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 3/4/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SPUStatusCompletionResults.h>
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
@protocol SPUStandardUserDriverDelegate;
|
||||
|
||||
SU_EXPORT @interface SPUUserDriverCoreComponent : NSObject
|
||||
|
||||
- (void)showCanCheckForUpdates:(BOOL)canCheckForUpdates;
|
||||
|
||||
@property (nonatomic, readonly) BOOL canCheckForUpdates;
|
||||
|
||||
- (void)registerInstallUpdateHandler:(void (^)(SPUInstallUpdateStatus))installUpdateHandler;
|
||||
- (void)installUpdateWithChoice:(SPUInstallUpdateStatus)choice;
|
||||
|
||||
- (void)registerUpdateCheckStatusHandler:(void (^)(SPUUserInitiatedCheckStatus))updateCheckStatusCompletion;
|
||||
- (void)cancelUpdateCheckStatus;
|
||||
- (void)completeUpdateCheckStatus;
|
||||
|
||||
- (void)registerDownloadStatusHandler:(void (^)(SPUDownloadUpdateStatus))downloadUpdateStatusCompletion;
|
||||
- (void)cancelDownloadStatus;
|
||||
- (void)completeDownloadStatus;
|
||||
|
||||
- (void)registerAcknowledgement:(void (^)(void))acknowledgement;
|
||||
- (void)acceptAcknowledgement;
|
||||
|
||||
- (void)dismissUpdateInstallation;
|
||||
|
||||
@end
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// SUAppcast.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 3/12/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUAPPCAST_H
|
||||
#define SUAPPCAST_H
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class SUAppcastItem;
|
||||
SU_EXPORT @interface SUAppcast : NSObject<NSURLDownloadDelegate>
|
||||
|
||||
@property (copy, nullable) NSString *userAgentString;
|
||||
@property (copy, nullable) NSDictionary<NSString *, NSString *> *httpHeaders;
|
||||
|
||||
- (void)fetchAppcastFromURL:(NSURL *)url inBackground:(BOOL)bg completionBlock:(void (^)(NSError *_Nullable))err;
|
||||
- (SUAppcast *)copyWithoutDeltaUpdates;
|
||||
|
||||
@property (readonly, copy, nullable) NSArray *items;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#endif
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// SUAppcastItem.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 3/12/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUAPPCASTITEM_H
|
||||
#define SUAPPCASTITEM_H
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
SU_EXPORT @interface SUAppcastItem : NSObject<NSSecureCoding>
|
||||
@property (copy, readonly) NSString *title;
|
||||
@property (copy, readonly) NSString *dateString;
|
||||
@property (copy, readonly) NSString *itemDescription;
|
||||
@property (strong, readonly) NSURL *releaseNotesURL;
|
||||
@property (copy, readonly) NSString *DSASignature;
|
||||
@property (copy, readonly) NSString *minimumSystemVersion;
|
||||
@property (copy, readonly) NSString *maximumSystemVersion;
|
||||
@property (strong, readonly) NSURL *fileURL;
|
||||
@property (nonatomic, readonly) uint64_t contentLength;
|
||||
@property (copy, readonly) NSString *versionString;
|
||||
@property (copy, readonly) NSString *osString;
|
||||
@property (copy, readonly) NSString *displayVersionString;
|
||||
@property (copy, readonly) NSDictionary *deltaUpdates;
|
||||
@property (strong, readonly) NSURL *infoURL;
|
||||
@property (nonatomic, copy, readonly) NSString *installationType;
|
||||
|
||||
// Initializes with data from a dictionary provided by the RSS class.
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict;
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict failureReason:(NSString **)error;
|
||||
|
||||
@property (getter=isDeltaUpdate, readonly) BOOL deltaUpdate;
|
||||
@property (getter=isCriticalUpdate, readonly) BOOL criticalUpdate;
|
||||
@property (getter=isMacOsUpdate, readonly) BOOL macOsUpdate;
|
||||
@property (getter=isInformationOnlyUpdate, readonly) BOOL informationOnlyUpdate;
|
||||
|
||||
// Returns the dictionary provided in initWithDictionary; this might be useful later for extensions.
|
||||
@property (readonly, copy) NSDictionary *propertiesDictionary;
|
||||
|
||||
- (NSURL *)infoURL;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
//
|
||||
// SUErrors.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by C.W. Betts on 10/13/14.
|
||||
// Copyright (c) 2014 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUERRORS_H
|
||||
#define SUERRORS_H
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
/**
|
||||
* Error domain used by Sparkle
|
||||
*/
|
||||
SU_EXPORT extern NSString *const SUSparkleErrorDomain;
|
||||
|
||||
typedef NS_ENUM(OSStatus, SUError) {
|
||||
// Configuration phase errors
|
||||
SUNoPublicDSAFoundError = 0001,
|
||||
SUInsufficientSigningError = 0002,
|
||||
SUInsecureFeedURLError = 0003,
|
||||
SUInvalidFeedURLError = 0004,
|
||||
SUInvalidUpdaterError = 0005,
|
||||
SUInvalidHostBundleIdentifierError = 0006,
|
||||
SUInvalidHostVersionError = 0007,
|
||||
|
||||
// Appcast phase errors.
|
||||
SUAppcastParseError = 1000,
|
||||
SUNoUpdateError = 1001,
|
||||
SUAppcastError = 1002,
|
||||
SURunningFromDiskImageError = 1003,
|
||||
SUResumeAppcastError = 1004,
|
||||
|
||||
// Download phase errors.
|
||||
SUTemporaryDirectoryError = 2000,
|
||||
SUDownloadError = 2001,
|
||||
|
||||
// Extraction phase errors.
|
||||
SUUnarchivingError = 3000,
|
||||
SUSignatureError = 3001,
|
||||
|
||||
// Installation phase errors.
|
||||
SUFileCopyFailure = 4000,
|
||||
SUAuthenticationFailure = 4001,
|
||||
SUMissingUpdateError = 4002,
|
||||
SUMissingInstallerToolError = 4003,
|
||||
SURelaunchError = 4004,
|
||||
SUInstallationError = 4005,
|
||||
SUDowngradeError = 4006,
|
||||
SUInstallationCanceledError = 4007,
|
||||
SUInstallationAuthorizeLaterError = 4008,
|
||||
SUNotAllowedInteractionError = 4009
|
||||
};
|
||||
|
||||
#endif
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// SUExport.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Jake Petroules on 2014-08-23.
|
||||
// Copyright (c) 2014 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUEXPORT_H
|
||||
#define SUEXPORT_H
|
||||
|
||||
#ifdef BUILDING_SPARKLE
|
||||
#define SU_EXPORT __attribute__((visibility("default")))
|
||||
#else
|
||||
#define SU_EXPORT
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// SUStandardVersionComparator.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 12/21/07.
|
||||
// Copyright 2007 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUSTANDARDVERSIONCOMPARATOR_H
|
||||
#define SUSTANDARDVERSIONCOMPARATOR_H
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#import <Sparkle/SUExport.h>
|
||||
#import <Sparkle/SUVersionComparisonProtocol.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
Sparkle's default version comparator.
|
||||
|
||||
This comparator is adapted from MacPAD, by Kevin Ballard.
|
||||
It's "dumb" in that it does essentially string comparison,
|
||||
in components split by character type.
|
||||
*/
|
||||
SU_EXPORT @interface SUStandardVersionComparator : NSObject <SUVersionComparison>
|
||||
|
||||
/*!
|
||||
Initializes a new instance of the standard version comparator.
|
||||
*/
|
||||
- (instancetype)init;
|
||||
|
||||
/*!
|
||||
Returns a singleton instance of the comparator.
|
||||
|
||||
It is usually preferred to alloc/init new a comparator instead.
|
||||
*/
|
||||
+ (SUStandardVersionComparator *)defaultComparator;
|
||||
|
||||
/*!
|
||||
Compares version strings through textual analysis.
|
||||
|
||||
See the implementation for more details.
|
||||
*/
|
||||
- (NSComparisonResult)compareVersion:(NSString *)versionA toVersion:(NSString *)versionB;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
#endif
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// SUUpdatePermissionResponse.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 2/8/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
/*!
|
||||
This class represents a response for permission to check updates.
|
||||
*/
|
||||
SU_EXPORT @interface SUUpdatePermissionResponse : NSObject<NSSecureCoding>
|
||||
|
||||
/*!
|
||||
Initializes a new update permission response instance.
|
||||
|
||||
@param automaticUpdateChecks Flag for whether to allow automatic update checks.
|
||||
@param sendSystemProfile Flag for if system profile information should be sent to the server hosting the appcast.
|
||||
*/
|
||||
- (instancetype)initWithAutomaticUpdateChecks:(BOOL)automaticUpdateChecks sendSystemProfile:(BOOL)sendSystemProfile;
|
||||
|
||||
/*!
|
||||
A read-only property indicating whether automatic update checks are allowed or not.
|
||||
*/
|
||||
@property (nonatomic, readonly) BOOL automaticUpdateChecks;
|
||||
|
||||
/*!
|
||||
A read-only property indicating if system profile should be sent or not.
|
||||
*/
|
||||
@property (nonatomic, readonly) BOOL sendSystemProfile;
|
||||
|
||||
@end
|
||||
+205
@@ -0,0 +1,205 @@
|
||||
//
|
||||
// SUUpdater.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 1/4/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUUPDATER_H
|
||||
#define SUUPDATER_H
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Cocoa;
|
||||
#else
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#endif
|
||||
#import <Sparkle/SUExport.h>
|
||||
#import <Sparkle/SUVersionComparisonProtocol.h>
|
||||
#import <Sparkle/SUVersionDisplayProtocol.h>
|
||||
#import <Sparkle/SUUpdaterDelegate.h>
|
||||
|
||||
@class SUAppcastItem, SUAppcast, NSMenuItem;
|
||||
|
||||
@protocol SUUpdaterDelegate;
|
||||
|
||||
/*!
|
||||
The main API in Sparkle for controlling the update mechanism.
|
||||
|
||||
This class is used to configure the update paramters as well as manually
|
||||
and automatically schedule and control checks for updates.
|
||||
|
||||
Note: This class is now deprecated and acts as a thin wrapper around SPUUpdater and SPUStandardUserDriver
|
||||
*/
|
||||
__deprecated_msg("Use SPUStandardUpdaterController or SPUUpdater instead")
|
||||
SU_EXPORT @interface SUUpdater : NSObject
|
||||
|
||||
@property (unsafe_unretained, nonatomic) IBOutlet id<SUUpdaterDelegate> delegate;
|
||||
|
||||
/*!
|
||||
The shared updater for the main bundle.
|
||||
|
||||
This is equivalent to passing [NSBundle mainBundle] to SUUpdater::updaterForBundle:
|
||||
*/
|
||||
+ (SUUpdater *)sharedUpdater;
|
||||
|
||||
/*!
|
||||
The shared updater for a specified bundle.
|
||||
If an updater has already been initialized for the provided bundle, that shared instance will be returned.
|
||||
*/
|
||||
+ (SUUpdater *)updaterForBundle:(NSBundle *)bundle;
|
||||
|
||||
/*!
|
||||
Designated initializer for SUUpdater.
|
||||
|
||||
If an updater has already been initialized for the provided bundle, that shared instance will be returned.
|
||||
*/
|
||||
- (instancetype)initForBundle:(NSBundle *)bundle;
|
||||
|
||||
/*!
|
||||
Explicitly checks for updates and displays a progress dialog while doing so.
|
||||
|
||||
This method is meant for a main menu item.
|
||||
Connect any menu item to this action in Interface Builder,
|
||||
and Sparkle will check for updates and report back its findings verbosely
|
||||
when it is invoked.
|
||||
|
||||
This will find updates that the user has opted into skipping.
|
||||
*/
|
||||
- (IBAction)checkForUpdates:(id)sender;
|
||||
|
||||
/*!
|
||||
The menu item validation used for the -checkForUpdates: action
|
||||
*/
|
||||
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem;
|
||||
|
||||
/*!
|
||||
Checks for updates, but does not display any UI unless an update is found.
|
||||
|
||||
This is meant for programmatically initating a check for updates. That is,
|
||||
it will display no UI unless it actually finds an update, in which case it
|
||||
proceeds as usual.
|
||||
|
||||
If automatic downloading of updates it turned on and allowed, however,
|
||||
this will invoke that behavior, and if an update is found, it will be downloaded
|
||||
in the background silently and will be prepped for installation.
|
||||
|
||||
This will not find updates that the user has opted into skipping.
|
||||
*/
|
||||
- (void)checkForUpdatesInBackground;
|
||||
|
||||
/*!
|
||||
A property indicating whether or not to check for updates automatically.
|
||||
|
||||
Setting this property will persist in the host bundle's user defaults.
|
||||
The update schedule cycle will be reset in a short delay after the property's new value is set.
|
||||
This is to allow reverting this property without kicking off a schedule change immediately
|
||||
*/
|
||||
@property (nonatomic) BOOL automaticallyChecksForUpdates;
|
||||
|
||||
/*!
|
||||
A property indicating whether or not updates can be automatically downloaded in the background.
|
||||
|
||||
Note that automatic downloading of updates can be disallowed by the developer.
|
||||
In this case, -automaticallyDownloadsUpdates will return NO regardless of how this property is set.
|
||||
|
||||
Setting this property will persist in the host bundle's user defaults.
|
||||
*/
|
||||
@property (nonatomic) BOOL automaticallyDownloadsUpdates;
|
||||
|
||||
/*!
|
||||
A property indicating the current automatic update check interval.
|
||||
|
||||
Setting this property will persist in the host bundle's user defaults.
|
||||
The update schedule cycle will be reset in a short delay after the property's new value is set.
|
||||
This is to allow reverting this property without kicking off a schedule change immediately
|
||||
*/
|
||||
@property (nonatomic) NSTimeInterval updateCheckInterval;
|
||||
|
||||
/*!
|
||||
Begins a "probing" check for updates which will not actually offer to
|
||||
update to that version.
|
||||
|
||||
However, the delegate methods
|
||||
SUUpdaterDelegate::updater:didFindValidUpdate: and
|
||||
SUUpdaterDelegate::updaterDidNotFindUpdate: will be called,
|
||||
so you can use that information in your UI.
|
||||
|
||||
Updates that have been skipped by the user will not be found.
|
||||
*/
|
||||
- (void)checkForUpdateInformation;
|
||||
|
||||
/*!
|
||||
The URL of the appcast used to download update information.
|
||||
|
||||
Setting this property will persist in the host bundle's user defaults.
|
||||
If you don't want persistence, you may want to consider instead implementing
|
||||
SUUpdaterDelegate::feedURLStringForUpdater: or SUUpdaterDelegate::feedParametersForUpdater:sendingSystemProfile:
|
||||
|
||||
This property must be called on the main thread.
|
||||
*/
|
||||
@property (nonatomic, copy) NSURL *feedURL;
|
||||
|
||||
/*!
|
||||
The host bundle that is being updated.
|
||||
*/
|
||||
@property (readonly, nonatomic) NSBundle *hostBundle;
|
||||
|
||||
/*!
|
||||
The bundle this class (SUUpdater) is loaded into.
|
||||
*/
|
||||
@property (nonatomic, readonly) NSBundle *sparkleBundle;
|
||||
|
||||
/*!
|
||||
The user agent used when checking for updates.
|
||||
|
||||
The default implementation can be overrided.
|
||||
*/
|
||||
@property (nonatomic, copy) NSString *userAgentString;
|
||||
|
||||
/*!
|
||||
The HTTP headers used when checking for updates.
|
||||
|
||||
The keys of this dictionary are HTTP header fields (NSString) and values are corresponding values (NSString)
|
||||
*/
|
||||
@property (copy) NSDictionary<NSString *, NSString *> *httpHeaders;
|
||||
|
||||
/*!
|
||||
A property indicating whether or not the user's system profile information is sent when checking for updates.
|
||||
|
||||
Setting this property will persist in the host bundle's user defaults.
|
||||
*/
|
||||
@property (nonatomic) BOOL sendsSystemProfile;
|
||||
|
||||
/*!
|
||||
A property indicating the decryption password used for extracting updates shipped as Apple Disk Images (dmg)
|
||||
*/
|
||||
@property (nonatomic, copy) NSString *decryptionPassword;
|
||||
|
||||
/*!
|
||||
Returns the date of last update check.
|
||||
|
||||
\returns \c nil if no check has been performed.
|
||||
*/
|
||||
@property (nonatomic, readonly, copy) NSDate *lastUpdateCheckDate;
|
||||
|
||||
/*!
|
||||
Appropriately schedules or cancels the update checking timer according to
|
||||
the preferences for time interval and automatic checks.
|
||||
|
||||
This call does not change the date of the next check,
|
||||
but only the internal NSTimer.
|
||||
*/
|
||||
- (void)resetUpdateCycle;
|
||||
|
||||
/*!
|
||||
A property indicating whether or not an update is in progress.
|
||||
|
||||
Note this property is not indicative of whether or not user initiated updates can be performed.
|
||||
Use SUUpdater::validateMenuItem: for that instead.
|
||||
*/
|
||||
@property (nonatomic, readonly) BOOL updateInProgress;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
+284
@@ -0,0 +1,284 @@
|
||||
//
|
||||
// SUUpdaterDelegate.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 3/12/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
@protocol SUVersionComparison, SUVersionDisplay;
|
||||
@class SUUpdater, SUAppcast, SUAppcastItem;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// SUUpdater Notifications for events that might be interesting to more than just the delegate
|
||||
// The updater will be the notification object
|
||||
// -----------------------------------------------------------------------------
|
||||
SU_EXPORT extern NSString *const SUUpdaterDidFinishLoadingAppCastNotification;
|
||||
SU_EXPORT extern NSString *const SUUpdaterDidFindValidUpdateNotification;
|
||||
SU_EXPORT extern NSString *const SUUpdaterDidNotFindUpdateNotification;
|
||||
SU_EXPORT extern NSString *const SUUpdaterWillRestartNotification;
|
||||
#define SUUpdaterWillRelaunchApplicationNotification SUUpdaterWillRestartNotification;
|
||||
#define SUUpdaterWillInstallUpdateNotification SUUpdaterWillRestartNotification;
|
||||
|
||||
// Key for the SUAppcastItem object in the SUUpdaterDidFindValidUpdateNotification userInfo
|
||||
SU_EXPORT extern NSString *const SUUpdaterAppcastItemNotificationKey;
|
||||
// Key for the SUAppcast object in the SUUpdaterDidFinishLoadingAppCastNotification userInfo
|
||||
SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// SUUpdater Delegate:
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/*!
|
||||
Provides methods to control the behavior of an SUUpdater object.
|
||||
*/
|
||||
__deprecated_msg("See SPUUpdaterDelegate instead")
|
||||
@protocol SUUpdaterDelegate <NSObject>
|
||||
@optional
|
||||
|
||||
/*!
|
||||
Returns whether to allow Sparkle to pop up.
|
||||
|
||||
For example, this may be used to prevent Sparkle from interrupting a setup assistant.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (BOOL)updaterMayCheckForUpdates:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Returns additional parameters to append to the appcast URL's query string.
|
||||
|
||||
This is potentially based on whether or not Sparkle will also be sending along the system profile.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param sendingProfile Whether the system profile will also be sent.
|
||||
|
||||
\return An array of dictionaries with keys: "key", "value", "displayKey", "displayValue", the latter two being specifically for display to the user.
|
||||
*/
|
||||
- (NSArray<NSDictionary<NSString *, NSString *> *> *)feedParametersForUpdater:(SUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile;
|
||||
|
||||
/*!
|
||||
Returns a custom appcast URL.
|
||||
|
||||
Override this to dynamically specify the entire URL.
|
||||
|
||||
An alternative may be to use SUUpdaterDelegate::feedParametersForUpdater:sendingSystemProfile:
|
||||
and let the server handle what kind of feed to provide.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (nullable NSString *)feedURLStringForUpdater:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Returns whether Sparkle should prompt the user about automatic update checks.
|
||||
|
||||
Use this to override the default behavior.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (BOOL)updaterShouldPromptForPermissionToCheckForUpdates:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called after Sparkle has downloaded the appcast from the remote server.
|
||||
|
||||
Implement this if you want to do some special handling with the appcast once it finishes loading.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param appcast The appcast that was downloaded from the remote server.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater didFinishLoadingAppcast:(SUAppcast *)appcast;
|
||||
|
||||
/*!
|
||||
Returns the item in the appcast corresponding to the update that should be installed.
|
||||
|
||||
If you're using special logic or extensions in your appcast,
|
||||
implement this to use your own logic for finding a valid update, if any,
|
||||
in the given appcast.
|
||||
|
||||
\param appcast The appcast that was downloaded from the remote server.
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (nullable SUAppcastItem *)bestValidUpdateInAppcast:(SUAppcast *)appcast forUpdater:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called when a valid update is found by the update driver.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater didFindValidUpdate:(SUAppcastItem *)item;
|
||||
|
||||
/*!
|
||||
Called when a valid update is not found.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (void)updaterDidNotFindUpdate:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called immediately before downloading the specified update.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be downloaded.
|
||||
\param request The mutable URL request that will be used to download the update.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater willDownloadUpdate:(SUAppcastItem *)item withRequest:(NSMutableURLRequest *)request;
|
||||
|
||||
/*!
|
||||
Called after the specified update failed to download.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param item The appcast item corresponding to the update that failed to download.
|
||||
\param error The error generated by the failed download.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater failedToDownloadUpdate:(SUAppcastItem *)item error:(NSError *)error;
|
||||
|
||||
/*!
|
||||
Called when the user clicks the cancel button while and update is being downloaded.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (void)userDidCancelDownload:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called immediately before installing the specified update.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)item;
|
||||
|
||||
/*!
|
||||
Returns whether the relaunch should be delayed in order to perform other tasks.
|
||||
|
||||
This is not called if the user didn't relaunch on the previous update,
|
||||
in that case it will immediately restart.
|
||||
|
||||
This may also not be called if the application is not going to relaunch after it terminates.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
\param invocation The invocation that must be completed with `[invocation invoke]` before continuing with the relaunch.
|
||||
|
||||
\return \c YES to delay the relaunch until \p invocation is invoked.
|
||||
*/
|
||||
- (BOOL)updater:(SUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)item untilInvoking:(NSInvocation *)invocation;
|
||||
|
||||
/*!
|
||||
Returns whether the application should be relaunched at all.
|
||||
|
||||
Some apps \b cannot be relaunched under certain circumstances.
|
||||
This method can be used to explicitly prevent a relaunch.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (BOOL)updaterShouldRelaunchApplication:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called immediately before relaunching.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (void)updaterWillRelaunchApplication:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called immediately after relaunching. SUUpdater delegate must be set before applicationDidFinishLaunching: to catch this event.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (void)updaterDidRelaunchApplication:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Returns an object that compares version numbers to determine their arithmetic relation to each other.
|
||||
|
||||
This method allows you to provide a custom version comparator.
|
||||
If you don't implement this method or return \c nil,
|
||||
the standard version comparator will be used. Note that the
|
||||
standard version comparator may be used during installation for preventing
|
||||
a downgrade, even if you provide a custom comparator here.
|
||||
|
||||
\sa SUStandardVersionComparator
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (nullable id<SUVersionComparison>)versionComparatorForUpdater:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Returns an object that formats version numbers for display to the user.
|
||||
If you don't implement this method or return \c nil, the standard version formatter will be used.
|
||||
|
||||
\sa SUUpdateAlert
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (nullable id <SUVersionDisplay>)versionDisplayerForUpdater:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Returns the path to the application which is used to relaunch after the update is installed.
|
||||
|
||||
The installer also waits for the termination of the application at this path.
|
||||
|
||||
The default is the path of the host bundle.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (nullable NSString *)pathToRelaunchForUpdater:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called before an updater shows a modal alert window,
|
||||
to give the host the opportunity to hide attached windows that may get in the way.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (void)updaterWillShowModalAlert:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called after an updater shows a modal alert window,
|
||||
to give the host the opportunity to hide attached windows that may get in the way.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
*/
|
||||
- (void)updaterDidShowModalAlert:(SUUpdater *)updater;
|
||||
|
||||
/*!
|
||||
Called when an update is scheduled to be silently installed on quit.
|
||||
|
||||
This is after an update has been automatically downloaded in the background.
|
||||
(i.e. SUUpdater::automaticallyDownloadsUpdates is YES)
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param item The appcast item corresponding to the update that is proposed to be installed.
|
||||
\param invocation Can be used to trigger an immediate silent install and relaunch.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater willInstallUpdateOnQuit:(SUAppcastItem *)item immediateInstallationInvocation:(NSInvocation *)invocation;
|
||||
|
||||
/*!
|
||||
Calls after an update that was scheduled to be silently installed on quit has been canceled.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param item The appcast item corresponding to the update that was proposed to be installed.
|
||||
|
||||
\deprecated This method is no longer invoked. The installer will try to its best ability to install the update.
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater didCancelInstallUpdateOnQuit:(SUAppcastItem *)item __deprecated;
|
||||
|
||||
/*!
|
||||
Called after an update is aborted due to an error.
|
||||
|
||||
\param updater The SUUpdater instance.
|
||||
\param error The error that caused the abort
|
||||
*/
|
||||
- (void)updater:(SUUpdater *)updater didAbortWithError:(NSError *)error;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// SUVersionComparisonProtocol.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 12/21/07.
|
||||
// Copyright 2007 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUVERSIONCOMPARISONPROTOCOL_H
|
||||
#define SUVERSIONCOMPARISONPROTOCOL_H
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
Provides version comparison facilities for Sparkle.
|
||||
*/
|
||||
@protocol SUVersionComparison
|
||||
|
||||
/*!
|
||||
An abstract method to compare two version strings.
|
||||
|
||||
Should return NSOrderedAscending if b > a, NSOrderedDescending if b < a,
|
||||
and NSOrderedSame if they are equivalent.
|
||||
*/
|
||||
- (NSComparisonResult)compareVersion:(NSString *)versionA toVersion:(NSString *)versionB; // *** MAY BE CALLED ON NON-MAIN THREAD!
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
#endif
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// SUVersionDisplayProtocol.h
|
||||
// EyeTV
|
||||
//
|
||||
// Created by Uli Kusterer on 08.12.09.
|
||||
// Copyright 2009 Elgato Systems GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#import <Sparkle/SUExport.h>
|
||||
|
||||
/*!
|
||||
Applies special display formatting to version numbers.
|
||||
*/
|
||||
@protocol SUVersionDisplay
|
||||
|
||||
/*!
|
||||
Formats two version strings.
|
||||
|
||||
Both versions are provided so that important distinguishing information
|
||||
can be displayed while also leaving out unnecessary/confusing parts.
|
||||
*/
|
||||
- (void)formatVersion:(NSString *_Nonnull*_Nonnull)inOutVersionA andVersion:(NSString *_Nonnull*_Nonnull)inOutVersionB;
|
||||
|
||||
@end
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// Sparkle.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 3/16/06. (Modified by CDHW on 23/12/07)
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SPARKLE_H
|
||||
#define SPARKLE_H
|
||||
|
||||
// This list should include the shared headers. It doesn't matter if some of them aren't shared (unless
|
||||
// there are name-space collisions) so we can list all of them to start with:
|
||||
|
||||
#import <Sparkle/SUExport.h>
|
||||
#import <Sparkle/SUAppcast.h>
|
||||
#import <Sparkle/SUAppcastItem.h>
|
||||
#import <Sparkle/SUStandardVersionComparator.h>
|
||||
#import <Sparkle/SPUUpdater.h>
|
||||
#import <Sparkle/SPUUpdaterDelegate.h>
|
||||
#import <Sparkle/SPUUpdaterSettings.h>
|
||||
#import <Sparkle/SPUStandardUpdaterController.h>
|
||||
#import <Sparkle/SUVersionComparisonProtocol.h>
|
||||
#import <Sparkle/SUVersionDisplayProtocol.h>
|
||||
#import <Sparkle/SUErrors.h>
|
||||
#import <Sparkle/SPUUpdatePermissionRequest.h>
|
||||
#import <Sparkle/SUUpdatePermissionResponse.h>
|
||||
#import <Sparkle/SPUUserDriver.h>
|
||||
#import <Sparkle/SPUStandardUserDriver.h>
|
||||
#import <Sparkle/SPUStandardUserDriverDelegate.h>
|
||||
#import <Sparkle/SPUUserDriverCoreComponent.h>
|
||||
#import <Sparkle/SPUDownloadData.h>
|
||||
|
||||
#import <Sparkle/SUUpdater.h> // deprecated
|
||||
#import <Sparkle/SUUpdaterDelegate.h> // deprecated
|
||||
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user