[Sparkle] Updated to version 2.1.0 for Sandbox

Sandbox requires Sparkle version 2 or newer anyway, so upgrade it.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
swiftingly
Christopher Snowhill 2022-06-20 03:46:36 -07:00
parent c23bece62c
commit 08107f4a41
246 changed files with 3270 additions and 2390 deletions

View File

@ -0,0 +1 @@
Versions/Current/Autoupdate

View File

@ -0,0 +1 @@
Versions/Current/Updater.app

View File

@ -1,25 +0,0 @@
//
// SPUDownloader.h
// Downloader
//
// Created by Mayur Pawashe on 4/1/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import "SPUDownloaderProtocol.h"
@protocol SPUDownloaderDelegate;
// This object implements the protocol which we have defined. It provides the actual behavior for the service. It is 'exported' by the service to make it available to the process hosting the service over an NSXPCConnection.
@interface SPUDownloader : NSObject <SPUDownloaderProtocol>
// Due to XPC remote object reasons, this delegate is strongly referenced
// Invoke cleanup when done with this instance
- (instancetype)initWithDelegate:(id <SPUDownloaderDelegate>)delegate;
@end

View File

@ -1,38 +0,0 @@
//
// SPUDownloaderDelegate.h
// Sparkle
//
// Created by Mayur Pawashe on 4/1/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
NS_ASSUME_NONNULL_BEGIN
@class SPUDownloadData;
@protocol SPUDownloaderDelegate <NSObject>
// This is only invoked for persistent downloads
- (void)downloaderDidSetDestinationName:(NSString *)destinationName temporaryDirectory:(NSString *)temporaryDirectory;
// Under rare cases, this may be called more than once, in which case the current progress should be reset back to 0
// This is only invoked for persistent downloads
- (void)downloaderDidReceiveExpectedContentLength:(int64_t)expectedContentLength;
// This is only invoked for persistent downloads
- (void)downloaderDidReceiveDataOfLength:(uint64_t)length;
// downloadData is nil if this is a persisent download, otherwise it's non-nil if it's a temporary download
- (void)downloaderDidFinishWithTemporaryDownloadData:(SPUDownloadData * _Nullable)downloadData;
- (void)downloaderDidFailWithError:(NSError *)error;
@end
NS_ASSUME_NONNULL_END

View File

@ -1,34 +0,0 @@
//
// SPUDownloaderProtocol.h
// PersistentDownloader
//
// Created by Mayur Pawashe on 4/1/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
NS_ASSUME_NONNULL_BEGIN
@class SPUURLRequest;
// The protocol that this service will vend as its API. This header file will also need to be visible to the process hosting the service.
@protocol SPUDownloaderProtocol
- (void)startPersistentDownloadWithRequest:(SPUURLRequest *)request bundleIdentifier:(NSString *)bundleIdentifier desiredFilename:(NSString *)desiredFilename;
- (void)startTemporaryDownloadWithRequest:(SPUURLRequest *)request;
- (void)downloadDidFinish;
- (void)cleanup;
- (void)cancel;
@end
NS_ASSUME_NONNULL_END

View File

@ -1,20 +0,0 @@
//
// SPUDownloaderSession.h
// Sparkle
//
// Created by Deadpikle on 12/20/17.
// Copyright © 2017 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import "SPUDownloader.h"
#import "SPUDownloaderProtocol.h"
NS_CLASS_AVAILABLE(NSURLSESSION_AVAILABLE, 7_0)
@interface SPUDownloaderSession : SPUDownloader <SPUDownloaderProtocol>
@end

View File

@ -1,35 +0,0 @@
//
// SPUURLRequest.h
// Sparkle
//
// Created by Mayur Pawashe on 5/19/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
NS_ASSUME_NONNULL_BEGIN
// A class that wraps NSURLRequest and implements NSSecureCoding
// This class exists because NSURLRequest did not support NSSecureCoding in macOS 10.8
// I have not verified if NSURLRequest in 10.9 implements NSSecureCoding or not
@interface SPUURLRequest : NSObject <NSSecureCoding>
// Creates a new URL request
// Only these properties are currently tracked:
// * URL
// * Cache policy
// * Timeout interval
// * HTTP header fields
// * networkServiceType
+ (instancetype)URLRequestWithRequest:(NSURLRequest *)request;
@property (nonatomic, readonly) NSURLRequest *request;
@end
NS_ASSUME_NONNULL_END

View File

@ -1,31 +0,0 @@
//
// SUAppcast.h
// Sparkle
//
// Created by Andy Matuschak on 3/12/06.
// Copyright 2006 Andy Matuschak. All rights reserved.
//
#ifndef SUAPPCAST_H
#define SUAPPCAST_H
#import <Foundation/Foundation.h>
#import "SUExport.h"
NS_ASSUME_NONNULL_BEGIN
@class SUAppcastItem;
SU_EXPORT @interface SUAppcast : NSObject
@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

View File

@ -1,58 +0,0 @@
//
// 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)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import "SUExport.h"
@class SUSignatures;
SU_EXPORT @interface SUAppcastItem : NSObject
@property (copy, readonly) NSString *title;
@property (copy, readonly) NSString *dateString;
@property (copy, readonly) NSDate *date;
@property (copy, readonly) NSString *itemDescription;
@property (strong, readonly) NSURL *releaseNotesURL;
@property (strong, readonly) SUSignatures *signatures;
@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 (copy, readonly) NSNumber* phasedRolloutInterval;
@property (copy, readonly) NSString *minimumAutoupdateVersion;
// 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

View File

@ -1,26 +0,0 @@
//
// SUCodeSigningVerifier.h
// Sparkle
//
// Created by Andy Matuschak on 7/5/12.
//
//
#ifndef SUCODESIGNINGVERIFIER_H
#define SUCODESIGNINGVERIFIER_H
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import "SUExport.h"
SU_EXPORT @interface SUCodeSigningVerifier : NSObject
+ (BOOL)codeSignatureAtBundleURL:(NSURL *)oldBundlePath matchesSignatureAtBundleURL:(NSURL *)newBundlePath error:(NSError **)error;
+ (BOOL)codeSignatureIsValidAtBundleURL:(NSURL *)bundlePath error:(NSError **)error;
+ (BOOL)bundleAtURLIsCodeSigned:(NSURL *)bundlePath;
+ (NSDictionary *)codeSignatureInfoAtBundleURL:(NSURL *)bundlePath;
@end
#endif

View File

@ -1,58 +0,0 @@
//
// 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 "SUExport.h"
/**
* Error domain used by Sparkle
*/
SU_EXPORT extern NSString *const SUSparkleErrorDomain;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++98-compat"
typedef NS_ENUM(OSStatus, SUError) {
// Appcast phase errors.
SUAppcastParseError = 1000,
SUNoUpdateError = 1001,
SUAppcastError = 1002,
SURunningFromDiskImageError = 1003,
SURunningTranslocated = 1004,
SUWebKitTerminationError = 1005,
// 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,
SUInstallationCancelledError = 4007,
// System phase errors
SUSystemPowerOffError = 5000
};
#pragma clang diagnostic pop
#endif

View File

@ -1,52 +0,0 @@
//
// 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 "SUExport.h"
#import "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

View File

@ -1,38 +0,0 @@
//
// 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:
#pragma clang diagnostic push
// Do not use <> style includes since 2.x has two frameworks that need to work: Sparkle and SparkleCore
#pragma clang diagnostic ignored "-Wquoted-include-in-framework-header"
#import "SUAppcast.h"
#import "SUAppcastItem.h"
#import "SUStandardVersionComparator.h"
#import "SUUpdater.h"
#import "SUUpdaterDelegate.h"
#import "SUVersionComparisonProtocol.h"
#import "SUVersionDisplayProtocol.h"
#import "SUErrors.h"
#import "SPUDownloader.h"
#import "SPUDownloaderDelegate.h"
#import "SPUDownloadData.h"
#import "SPUDownloaderProtocol.h"
#import "SPUDownloaderSession.h"
#import "SPUURLRequest.h"
#import "SUCodeSigningVerifier.h"
#pragma clang diagnostic pop
#endif

View File

@ -1,21 +0,0 @@
//
// SUUnarchiver.h
// Sparkle
//
// Created by Andy Matuschak on 3/16/06.
// Copyright 2006 Andy Matuschak. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol SUUnarchiverProtocol;
@interface SUUnarchiver : NSObject
+ (nullable id <SUUnarchiverProtocol>)unarchiverForPath:(NSString *)path updatingHostBundlePath:(nullable NSString *)hostPath decryptionPassword:(nullable NSString *)decryptionPassword;
@end
NS_ASSUME_NONNULL_END

View File

@ -1,11 +0,0 @@
/* Class = "NSButtonCell"; title = "Install and Relaunch"; ObjectID = "41"; */
"41.title" = "Reinicia el programa ara";
/* Class = "NSButtonCell"; title = "Install on Quit"; ObjectID = "42"; */
"42.title" = "Reinicia el programa més tard";
/* Class = "NSButtonCell"; title = "Automatically download and install updates in the future"; ObjectID = "43"; */
"43.title" = "Baixa i instal·la les actualitzacions automàticament en el futur";
/* Class = "NSButtonCell"; title = "Don't Install"; ObjectID = "44"; */
"44.title" = "Don't Install";

View File

@ -1,11 +0,0 @@
/* Class = "NSButtonCell"; title = "Install and Relaunch"; ObjectID = "41"; */
"41.title" = "Instalovat a znovu spustit";
/* Class = "NSButtonCell"; title = "Install on Quit"; ObjectID = "42"; */
"42.title" = "Instalovat a ukončit";
/* Class = "NSButtonCell"; title = "Automatically download and install updates in the future"; ObjectID = "43"; */
"43.title" = "V budoucnu stahovat a instalovat aktualizace automaticky";
/* Class = "NSButtonCell"; title = "Don't Install"; ObjectID = "44"; */
"44.title" = "Neinstalovat";

View File

@ -1,12 +0,0 @@
/* Class = "NSButtonCell"; title = "Install and Relaunch"; ObjectID = "41"; */
"41.title" = "Install and Relaunch";
/* Class = "NSButtonCell"; title = "Install on Quit"; ObjectID = "42"; */
"42.title" = "Install on Quit";
/* Class = "NSButtonCell"; title = "Automatically download and install updates in the future"; ObjectID = "43"; */
"43.title" = "Automatically download and install updates in the future";
/* Class = "NSButtonCell"; title = "Don't Install"; ObjectID = "44"; */
"44.title" = "Don't Install";

View File

@ -1,11 +0,0 @@
/* Class = "NSButtonCell"; title = "Install and Relaunch"; ObjectID = "41"; */
"41.title" = "אתחל עכשיו";
/* Class = "NSButtonCell"; title = "Install on Quit"; ObjectID = "42"; */
"42.title" = "אתחל מאוחר יותר";
/* Class = "NSButtonCell"; title = "Automatically download and install updates in the future"; ObjectID = "43"; */
"43.title" = "הורד והתקן עדכונים אוטומטית גם בעתיד";
/* Class = "NSButtonCell"; title = "Don't Install"; ObjectID = "44"; */
"44.title" = "Don't Install";

Binary file not shown.

View File

@ -7,33 +7,49 @@
//
#if __has_feature(modules)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#ifdef BUILDING_SPARKLE_DOWNLOADER_SERVICE
// Ignore incorrect warning
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wquoted-include-in-framework-header"
#import "SUExport.h"
#pragma clang diagnostic pop
#else
#import <Sparkle/SUExport.h>
#endif
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 URL that was fetched from.
*
* This may be different from the URL in the request if there were redirects involved.
*/
@property (nonatomic, readonly, copy) NSURL *URL;
/**
* 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;

View File

@ -0,0 +1,116 @@
//
// SPUStandardUpdaterController.h
// Sparkle
//
// Created by Mayur Pawashe on 2/28/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import <Sparkle/SUExport.h>
NS_ASSUME_NONNULL_BEGIN
@class SPUUpdater;
@class SPUStandardUserDriver;
@class NSMenuItem;
@protocol SPUUserDriver, SPUUpdaterDelegate, SPUStandardUserDriverDelegate;
/**
A controller class that instantiates a `SPUUpdater` and allows binding UI to its updater settings.
This class can be instantiated in a nib or created programatically using `-initWithUpdaterDelegate:userDriverDelegate:` or `-initWithStartingUpdater:updaterDelegate: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) but it works well programatically too.
The controller creates an `SPUUpdater` instance using a `SPUStandardUserDriver` and allows hooking up the check for updates action and handling menu item validation.
It also allows hooking up the updater's and user driver's delegates.
If you need more control over what bundle you want to update, or you want to provide a custom user interface (via `SPUUserDriver`), please use `SPUUpdater` directly instead.
*/
SU_EXPORT @interface SPUStandardUpdaterController : NSObject
{
/**
* Interface builder outlet for the updater's delegate.
*/
IBOutlet __weak id<SPUUpdaterDelegate> updaterDelegate;
/**
* Interface builder outlet for the user driver's delegate.
*/
IBOutlet __weak id<SPUStandardUserDriverDelegate> userDriverDelegate;
}
/**
Accessible property for the updater. Some properties on the updater can be binded via KVO
When instantiated from a nib, don't perform update checks before the application has finished launching in a MainMenu nib (i.e applicationDidFinishLaunching:) or before the corresponding window/view controller has been loaded (i.e, windowDidLoad or viewDidLoad). The updater is not guaranteed to be started yet before these points.
*/
@property (nonatomic, readonly) SPUUpdater *updater;
/**
Accessible property for the updater's user driver.
*/
@property (nonatomic, readonly) SPUStandardUserDriver *userDriver;
/**
Create a new `SPUStandardUpdaterController` from a nib.
You cannot call this initializer directly. You must instantiate a `SPUStandardUpdaterController` inside of a nib (typically the MainMenu nib) to use it.
To create a `SPUStandardUpdaterController` programatically, use `-initWithUpdaterDelegate:userDriverDelegate:` or `-initWithStartingUpdater:updaterDelegate:userDriverDelegate:` instead.
*/
- (instancetype)init NS_UNAVAILABLE;
/**
Create a new `SPUStandardUpdaterController` programmatically.
The updater is started automatically. See `-startUpdater` for more information.
*/
- (instancetype)initWithUpdaterDelegate:(nullable id<SPUUpdaterDelegate>)updaterDelegate userDriverDelegate:(nullable id<SPUStandardUserDriverDelegate>)userDriverDelegate;
/**
Create a new `SPUStandardUpdaterController` programmatically allowing you to specify whether or not to start the updater immediately.
You can specify whether or not you want to start the updater immediately.
If you do not start the updater, you must invoke `-startUpdater` at a later time to start it.
*/
- (instancetype)initWithStartingUpdater:(BOOL)startUpdater updaterDelegate:(nullable id<SPUUpdaterDelegate>)updaterDelegate userDriverDelegate:(nullable id<SPUStandardUserDriverDelegate>)userDriverDelegate;
/**
Starts the updater if it has not already been started.
You should only call this method yourself if you opted out of starting the updater on initialization.
Hence, do not call this yourself if you are instantiating this controller from a nib.
This invokes `-[SPUUpdater startUpdater:]`. If the application is misconfigured with Sparkle, an error is logged and an alert is shown to the user (after a few seconds) to contact the developer.
If you want more control over this behavior, you can create your own `SPUUpdater` instead of using `SPUStandardUpdaterController`.
*/
- (void)startUpdater;
/**
Explicitly checks for updates and displays a progress dialog while doing so.
This method is meant for a main menu item.
Connect any NSMenuItem to this action in Interface Builder or programmatically,
and Sparkle will check for updates and report back its findings verbosely when it is invoked.
When the target/action of the menu item is set to this controller and this method,
this controller also handles enabling/disabling the menu item by checking
`-[SPUUpdater canCheckForUpdates]`
This action checks updates by invoking `-[SPUUpdater checkForUpdates]`
*/
- (IBAction)checkForUpdates:(nullable id)sender;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,44 @@
//
// SPUStandardUserDriver.h
// Sparkle
//
// Created by Mayur Pawashe on 2/14/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import <Sparkle/SPUUserDriver.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>
/**
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 optional delegate to this user driver.
*/
- (instancetype)initWithHostBundle:(NSBundle *)hostBundle delegate:(nullable id<SPUStandardUserDriverDelegate>)delegate;
/**
Use initWithHostBundle:delegate: instead.
*/
- (instancetype)init NS_UNAVAILABLE;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,64 @@
//
// SPUStandardUserDriverDelegate.h
// Sparkle
//
// Created by Mayur Pawashe on 3/3/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
@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;
/**
Handles showing the full release notes to the user.
When a user checks for new updates and no new update is found, Sparkle will offer to show the application's version history to the user
by providing a "Version History" button in the no new update available alert.
If this delegate method is not implemented, Sparkle will instead offer to open the
`fullReleaseNotesLink` (or `releaseNotesLink` if the former is unavailable) from the appcast's latest `item` in the user's web browser.
If this delegate method is implemented, Sparkle will instead ask the delegate to show the full release notes to the user.
A delegate may want to implement this method if they want to show in-app or offline release notes.
@param item The appcast item corresponding to the latest version available.
*/
- (void)standardUserDriverShowVersionHistoryForAppcastItem:(SUAppcastItem *_Nonnull)item;
@end

View File

@ -0,0 +1,33 @@
//
// SPUUpdateCheck.h
// SPUUpdateCheck
//
// Created by Mayur Pawashe on 8/28/21.
// Copyright © 2021 Sparkle Project. All rights reserved.
//
#ifndef SPUUpdateCheck_h
#define SPUUpdateCheck_h
/**
Describes the type of update check being performed.
Each update check corresponds to an update check method on `SPUUpdater`.
*/
typedef NS_ENUM(NSInteger, SPUUpdateCheck)
{
/**
The user-initiated update check corresponding to `-[SPUUpdater checkForUpdates]`.
*/
SPUUpdateCheckUpdates = 0,
/**
The background scheduled update check corresponding to `-[SPUUpdater checkForUpdatesInBackground]`.
*/
SPUUpdateCheckUpdatesInBackground = 1,
/**
The informational probe update check corresponding to `-[SPUUpdater checkForUpdateInformation]`.
*/
SPUUpdateCheckUpdateInformation = 2
};
#endif /* SPUUpdateCheck_h */

View File

@ -0,0 +1,40 @@
//
// SPUUpdatePermissionRequest.h
// Sparkle
//
// Created by Mayur Pawashe on 8/14/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
@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

View File

@ -0,0 +1,301 @@
//
// SPUUpdater.h
// Sparkle
//
// Created by Andy Matuschak on 1/4/06.
// Copyright 2006 Andy Matuschak. All rights reserved.
//
#if __has_feature(modules)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
@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.
For convenience, you can create a standard or nib instantiable updater by using `SPUStandardUpdaterController`.
Prefer to set initial properties in your bundle's Info.plist as described in [Customizing Sparkle](https://sparkle-project.org/documentation/customization/).
Otherwise only if you need dynamic behavior (eg. for user preferences) should you set properties on the updater such as:
- `automaticallyChecksForUpdates`
- `updateCheckInterval`
- `automaticallyDownloadsUpdates`
- `feedURL`
Please view the documentation on each of these properties for more detail if you are to configure them dynamically.
*/
SU_EXPORT @interface SPUUpdater : NSObject
/**
Initializes a new `SPUUpdater` instance
This creates an updater, but to start it and schedule update checks `-startUpdater:` needs to be invoked first.
Related: See `SPUStandardUpdaterController` which wraps a `SPUUpdater` instance and is suitable for instantiating inside of nib files.
@param hostBundle The bundle that should be targetted for updating.
@param applicationBundle The application bundle that should be waited for termination and relaunched (unless overridden). 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`.
*/
- (instancetype)initWithHostBundle:(NSBundle *)hostBundle applicationBundle:(NSBundle *)applicationBundle userDriver:(id <SPUUserDriver>)userDriver delegate:(nullable id<SPUUpdaterDelegate>)delegate;
/**
Use `-initWithHostBundle:applicationBundle:userDriver:delegate:` or `SPUStandardUpdaterController` standard adapter instead.
If you want to drop an updater into a nib, use `SPUStandardUpdaterController`.
*/
- (instancetype)init NS_UNAVAILABLE;
/**
Starts the updater.
This method first checks if Sparkle is configured properly. A valid feed URL should be set before this method is invoked.
If the configuration is valid, an update cycle is started in the next main runloop cycle.
During this cycle, a permission prompt may be brought up (if needed) for checking if the user wants automatic update checking.
Otherwise if automatic update checks are enabled, a scheduled update alert may be brought up if enough time has elapsed since the last check.
See `automaticallyChecksForUpdates` for more information.
After starting the updater and before the next runloop cycle, one of `-checkForUpdates`, `-checkForUpdatesInBackground`, or `-checkForUpdateInformation` can be invoked.
This may be useful if you want to check for updates immediately or without showing a potential permission prompt.
If the updater cannot be started (i.e, due to a configuration issue in the application), you may want to fall back appropriately.
For example, the standard updater controller (`SPUStandardUpdaterController`) alerts the user that the app is misconfigured and to contact the developer.
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 if needed.
This is meant for users initiating a new update check or checking the current update progress.
If an update hasn't started, the user may be shown that a new check for updates is occurring.
If an update has already been downloaded or begun installing from a previous session, the user may be presented to install that update.
If the user is already being presented with an update, that update will be shown to the user in active focus.
This will find updates that the user has previously opted into skipping.
See `canCheckForUpdates` property which can determine when this method may be invoked.
*/
- (void)checkForUpdates;
/**
Checks for updates, but does not display any UI unless an update is found.
You usually do not need to call this method directly. If `automaticallyChecksForUpdates` is @c YES,
Sparkle calls this method automatically according to its update schedule using the `updateCheckInterval`
and the `lastUpdateCheckDate`.
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.
This method does not do anything if there is a `sessionInProgress`.
*/
- (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.
`-[SPUUpdaterDelegate updater:didFinishUpdateCycleForUpdateCheck:error:]` will be called when
this probing check is completed.
Updates that have been skipped by the user will not be found.
This method does not do anything if there is a `sessionInProgress`.
*/
- (void)checkForUpdateInformation;
/**
A property indicating whether or not updates can be checked by the user.
An update check can be made by the user when an update session isn't in progress, or when an update or its progress is being shown to the user.
A user cannot check for updates when data (such as the feed or an update) is still being downloaded automatically in the background.
This property is suitable to use for menu item validation for seeing if `-checkForUpdates` can be invoked.
This property is also KVO-compliant.
Note this property does not reflect whether or not an update session is in progress. Please see `sessionInProgress` property instead.
*/
@property (nonatomic, readonly) BOOL canCheckForUpdates;
/**
A property indicating whether or not an update session is in progress.
An update session is in progress when the appcast is being downloaded, an update is being downloaded,
an update is being shown, update permission is being requested, or the installer is being started.
An active session is when Sparkle's fired scheduler is running.
Note an update session may not be running even though Sparkle's installer (ran as a separate process) may be running,
or even though the update has been downloaded but the installation has been deferred. In both of these cases, a new update session
may be activated with the update resumed at a later point (automatically or manually).
See also:
- `canCheckForUpdates` property which is more suited for menu item validation and deciding if the user can initiate update checks.
- `-[SPUUpdaterDelegate updater:didFinishUpdateCycleForUpdateCheck:error:]` which lets the updater delegate know when an update cycle and session finishes.
*/
@property (nonatomic, readonly) BOOL sessionInProgress;
/**
A property indicating whether or not to check for updates automatically.
By default, Sparkle asks users on second launch for permission if they want automatic update checks enabled
and sets this property based on their response. If `SUEnableAutomaticChecks` is set in the Info.plist,
this permission request is not performed however.
Setting this property will persist in the host bundle's user defaults.
Only set this property if you need dynamic behavior (e.g. user preferences).
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 in seconds.
Setting this property will persist in the host bundle's user defaults.
For this reason, only set this property if you need dynamic behavior (eg user preferences).
Otherwise prefer to set SUScheduledCheckInterval directly in your Info.plist.
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.
By default, updates are not automatically downloaded.
Note that the developer can disallow automatic downloading of updates from being enabled.
In this case, this property will return NO regardless of how this property is set.
Setting this property will persist in the host bundle's user defaults.
For this reason, only set this property if you need dynamic behavior (eg user preferences).
Otherwise prefer to set SUAutomaticallyUpdate directly in your Info.plist.
*/
@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, returns nil.
This property must be called on the main thread; calls from background threads will return nil.
*/
@property (nonatomic, readonly, nullable) 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 implementing
`-[SPUUpdaterDelegate feedURLStringForUpdater:]` instead of using this method.
Passing nil will remove any feed URL that has been set in the host bundle's user defaults.
If you do not need to alternate between multiple feeds, set the SUFeedURL in your Info.plist instead of invoking this method.
For beta updates, you may consider migrating to `-[SPUUpdaterDelegate allowedChannelsForUpdater:]` in the future.
This method must be called on the main thread; calls from background threads will have no effect.
*/
- (void)setFeedURL:(nullable NSURL *)feedURL;
/**
The host bundle that is being updated.
*/
@property (nonatomic, readonly) NSBundle *hostBundle;
/**
The user agent used when checking for updates.
By default the user agent string returned is in the format:
$(BundleDisplayName)/$(BundleDisplayVersion) Sparkle/$(SparkleDisplayVersion)
BundleDisplayVersion is derived from the main application's Info.plist's CFBundleShortVersionString.
Note if Sparkle is being used to update another application, the bundle information retrieved is from the main application performing the updating.
This default implementation can be overrided.
*/
@property (nonatomic, copy) NSString *userAgentString;
/**
The HTTP headers used when checking for updates, downloading release notes, and downloading updates.
The keys of this dictionary are HTTP header fields and values are corresponding values.
*/
@property (nonatomic, copy, nullable) 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;
/**
The date of the last update check or nil if no check has been performed yet.
For testing purposes, the last update check is stored in the `SULastCheckTime` key in the host bundle's user defaults.
For example, `defaults delete my-bundle-id SULastCheckTime` can be invoked to clear the last update check time and test
if update checks are automatically scheduled.
*/
@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.
If you change the `updateCheckInterval` or `automaticallyChecksForUpdates` properties, the update cycle will be reset automatically after a short delay.
The update cycle is also started automatically after the updater is started. In all these cases, this method should not be called directly.
This call does not change the date of the next check, but only the internal timer.
*/
- (void)resetUpdateCycle;
/**
The system profile information that is sent when checking for updates.
*/
@property (nonatomic, readonly, copy) NSArray<NSDictionary<NSString *, NSString *> *> *systemProfileArray;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,458 @@
//
// SPUUpdaterDelegate.h
// Sparkle
//
// Created by Mayur Pawashe on 8/12/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import <Sparkle/SUExport.h>
#import <Sparkle/SPUUpdateCheck.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;
// -----------------------------------------------------------------------------
// System Profile Keys
// -----------------------------------------------------------------------------
SU_EXPORT extern NSString *const SUSystemProfilerApplicationNameKey;
SU_EXPORT extern NSString *const SUSystemProfilerApplicationVersionKey;
SU_EXPORT extern NSString *const SUSystemProfilerCPU64bitKey;
SU_EXPORT extern NSString *const SUSystemProfilerCPUCountKey;
SU_EXPORT extern NSString *const SUSystemProfilerCPUFrequencyKey;
SU_EXPORT extern NSString *const SUSystemProfilerCPUTypeKey;
SU_EXPORT extern NSString *const SUSystemProfilerCPUSubtypeKey;
SU_EXPORT extern NSString *const SUSystemProfilerHardwareModelKey;
SU_EXPORT extern NSString *const SUSystemProfilerMemoryKey;
SU_EXPORT extern NSString *const SUSystemProfilerOperatingSystemVersionKey;
SU_EXPORT extern NSString *const SUSystemProfilerPreferredLanguageKey;
// -----------------------------------------------------------------------------
// SPUUpdater Delegate:
// -----------------------------------------------------------------------------
/**
Provides delegation methods to control the behavior of an `SPUUpdater` object.
*/
@protocol SPUUpdaterDelegate <NSObject>
@optional
/**
Returns whether to allow Sparkle to check for updates.
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.
Note in Swift, this method returns Void and is marked with the throws keyword. If this method
doesn't throw an error, the updater may perform an update check. Otherwise if an error is thrown (we recommend using an NSError),
then the updater may not perform an update check.
@param updater The updater instance.
@param updateCheck The type of update check that will be performed if the updater is allowed to check for updates.
@param error The populated error object if the updater may not perform a new update check. The @c NSLocalizedDescriptionKey user info key should be populated indicating a description of the error.
@return @c YES if the updater is allowed to check for updates, otherwise @c NO
*/
- (BOOL)updater:(SPUUpdater *)updater mayPerformUpdateCheck:(SPUUpdateCheck)updateCheck error:(NSError * __autoreleasing *)error;
/**
Returns the set of Sparkle channels the updater is allowed to find new updates from.
An appcast item can specify a channel the update is posted to. Without specifying a channel, the appcast item is posted to the default channel.
For instance:
```
<item>
<sparkle:version>2.0 Beta 1</sparkle:version>
<sparkle:channel>beta</sparkle:channel>
</item>
```
This example posts an update to the @c beta channel, so only updaters that are allowed to use the @c beta channel can find this update.
If the @c <sparkle:channel> element is not present, the update item is posted to the default channel and can be found by any updater.
You can pick any name you'd like for the channel. The valid characters for channel names are letters, numbers, dashes, underscores, and periods.
Note to use this feature, all app versions that your users may update from in your feed must use a version of Sparkle that supports this feature.
This feature was added in Sparkle 2.
@return The set of channel names the updater is allowed to find new updates in. An empty set is the default behavior,
which means the updater will only look for updates in the default channel.
*/
- (NSSet<NSString *> *)allowedChannelsForUpdater:(SPUUpdater *)updater;
/**
Returns a custom appcast URL used for checking for new updates.
Override this to dynamically specify the feed URL.
@param updater The updater instance.
@return An appcast feed URL to check for new updates in, or @c nil for the default behavior and if you don't want to be delegated this task.
*/
- (nullable NSString *)feedURLStringForUpdater:(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.
*/
- (NSArray<NSDictionary<NSString *, NSString *> *> *)feedParametersForUpdater:(SPUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile;
/**
Returns whether Sparkle should prompt the user about checking for new updates automatically.
Use this to override the default behavior.
@param updater The updater instance.
@return @c YES if the updater should prompt for permission to check for new updates automatically, otherwise @c NO
*/
- (BOOL)updaterShouldPromptForPermissionToCheckForUpdates:(SPUUpdater *)updater;
/**
Returns an allowed list of system profile keys to be appended to the appcast URL's query string.
By default all keys will be included. This method allows overriding which keys should only be allowed.
@param updater The updater instance.
@return An array of system profile keys to include in the appcast URL's query string. Elements must be one of the `SUSystemProfiler*Key` constants. Return @c nil for the default behavior and if you don't want to be delegated this task.
*/
- (nullable NSArray<NSString *> *)allowedSystemProfileKeysForUpdater:(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;
/**
Called when a new 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 new update is not found.
There are various reasons a new update is unavailable and can't be installed.
The userInfo dictionary on the error is populated with three keys:
- `SPULatestAppcastItemFoundKey`: if available, this may provide the latest `SUAppcastItem` that was found. This will be @c nil if it's unavailable.
- `SPUNoUpdateFoundReasonKey`: This will provide the `SPUNoUpdateFoundReason`.
For example the reason could be because the latest version in the feed requires a newer OS version or could be because the user is already on the latest version.
- `SPUNoUpdateFoundUserInitiatedKey`: A boolean that indicates if a new update was not found when the user intitiated an update check manually.
@param updater The updater instance.
@param error An error containing information on why a new valid update was not found
*/
- (void)updaterDidNotFindUpdate:(SPUUpdater *)updater error:(NSError *)error;
/**
Called when a valid new update is not found.
If more information is needed on why an update was not found, use `-[SPUUpdaterDelegate updaterDidNotFindUpdate:error:]` instead.
@param updater The updater instance.
*/
- (void)updaterDidNotFindUpdate:(SPUUpdater *)updater;
/**
Returns the item in the appcast corresponding to the update that should be installed.
Please consider using or migrating to other supported features before adopting this method.
Specifically:
- If you want to filter out certain tagged updates (like beta updates), consider `-[SPUUpdaterDelegate allowedChannelsForUpdater:]` instead.
- If you want to treat certain updates as informational-only, consider supplying @c <sparkle:informationalUpdate> with a set of affected versions users are updating from.
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.
Do not base your logic by filtering out items with a minimum or maximum OS version or minimum autoupdate version
because Sparkle already has logic for determining whether or not those items should be filtered out.
Also do not return a non-top level item from the appcast such as a delta item. Delta items will be ignored.
Sparkle picks the delta item from your selection if the appropriate one is available.
This method will not be invoked with an appcast that has zero items. Pick the best item from the appcast.
If an item is available that has the same version as the application or bundle to update, do not pick an item that is worse than that version.
This method may be called multiple times for different selections and filters. This method should be efficient.
Return `+[SUAppcastItem emptyAppcastItem]` if no appcast item is valid.
Return @c nil if you don't want to be delegated this task and want to let Sparkle handle picking the best valid update.
@param appcast The appcast that was downloaded from the remote server.
@param updater The updater instance.
@return The best valid appcast item.
*/
- (nullable SUAppcastItem *)bestValidUpdateInAppcast:(SUAppcast *)appcast forUpdater:(SPUUpdater *)updater;
/**
Returns whether or not the updater should proceed with the new chosen update from the appcast.
By default, the updater will always proceed with the best selected update found in an appcast. Override this to override this behavior.
If you return @c NO and populate the @c error, the user is not shown this @c updateItem nor is the update downloaded or installed.
Note in Swift, this method returns Void and is marked with the throws keyword. If this method doesn't throw an error, the updater will proceed with the update.
Otherwise if an error is thrown (we recommend using an NSError), then the will not proceed with the update.
@param updater The updater instance.
@param updateItem The selected update item to proceed with.
@param updateCheck The type of update check that would be performed if proceeded.
@param error An error object that must be populated by the delegate if the updater should not proceed with the update. The @c NSLocalizedDescriptionKey user info key should be populated indicating a description of the error.
@return @c YES if the updater should proceed with @c updateItem, otherwise @c NO if the updater should not proceed with the update with an @c error populated.
*/
- (BOOL)updater:(SPUUpdater *)updater shouldProceedWithUpdate:(SUAppcastItem *)updateItem updateCheck:(SPUUpdateCheck)updateCheck error:(NSError * __autoreleasing *)error;
/**
Called when an update is skipped by the user.
@param updater The updater instance.
@param item The appcast item corresponding to the update that the user skipped.
*/
- (void)updater:(SPUUpdater *)updater userDidSkipThisVersion:(SUAppcastItem *)item;
/**
Returns whether the release notes (if available) should be downloaded after an update is found and shown.
This is specifically for the @c <releaseNotesLink> element in the appcast item.
@param updater The updater instance.
@param updateItem The update item to download and show release notes from.
@return @c YES to download and show the release notes if available, otherwise @c NO. The default behavior is @c YES.
*/
- (BOOL)updater:(SPUUpdater *)updater shouldDownloadReleaseNotesForUpdate:(SUAppcastItem *)updateItem;
/**
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 immediately after succesfull download of the specified update.
@param updater The SUUpdater instance.
@param item The appcast item corresponding to the update that has been downloaded.
*/
- (void)updater:(SPUUpdater *)updater didDownloadUpdate:(SUAppcastItem *)item;
/**
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 cancels an update while it is being downloaded.
@param updater The updater instance.
*/
- (void)userDidCancelDownload:(SPUUpdater *)updater;
/**
Called immediately before extracting the specified downloaded update.
@param updater The SUUpdater instance.
@param item The appcast item corresponding to the update that is proposed to be extracted.
*/
- (void)updater:(SPUUpdater *)updater willExtractUpdate:(SUAppcastItem *)item;
/**
Called immediately after extracting the specified downloaded update.
@param updater The SUUpdater instance.
@param item The appcast item corresponding to the update that has been extracted.
*/
- (void)updater:(SPUUpdater *)updater didExtractUpdate:(SUAppcastItem *)item;
/**
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 @c 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 **cannot** be relaunched under certain circumstances.
This method can be used to explicitly prevent a relaunch.
@param updater The updater instance.
@return @c YES if the updater should be relaunched, otherwise @c 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.
@param updater The updater instance.
@return The custom version comparator or @c nil if you don't want to be delegated this task.
*/
- (nullable id<SUVersionComparison>)versionComparatorForUpdater:(SPUUpdater *)updater;
/**
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 in seconds until the next scheduled update will occur. This is an approximation and may vary due to system state.
@param updater The updater instance.
*/
- (void)updater:(SPUUpdater *)updater willScheduleUpdateCheckAfterDelay:(NSTimeInterval)delay;
/**
Called when no update checks will be scheduled in the future.
This may later change if automatic update checks become enabled.
@param updater The updater instance.
*/
- (void)updaterWillNotScheduleUpdateCheck:(SPUUpdater *)updater;
/**
Returns the decryption password (if any) which is used to extract the update archive DMG.
Return @c nil if no password should be used.
@param updater The updater instance.
@return The password used for decrypting the archive, or @c 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.
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 @c immediateInstallHandler is not invoked, the installer will attempt to install the update on termination.
@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 @c YES if the delegate will handle installing the update or @c NO if the updater should be given responsibility.
*/
- (BOOL)updater:(SPUUpdater *)updater willInstallUpdateOnQuit:(SUAppcastItem *)item immediateInstallationBlock:(void (^)(void))immediateInstallHandler;
/**
Called after the update driver aborts due to an error.
The update driver runs when checking for updates. This delegate method is called an error occurs during this process.
Some special possible values of `error.code` are:
- `SUNoUpdateError`: No new update was found.
- `SUInstallationCanceledError`: The user canceled installing the update when requested for authorization.
@param updater The updater instance.
@param error The error that caused the update driver to abort.
*/
- (void)updater:(SPUUpdater *)updater didAbortWithError:(NSError *)error;
/**
Called after the update driver finishes.
The update driver runs when checking for updates. This delegate method is called when that check is finished.
An update may be scheduled to be installed during the update cycle, or no updates may be found, or an available update may be dismissed or skipped (which is the same as no error).
If the @c error is @c nil, no error has occurred.
Some special possible values of `error.code` are:
- `SUNoUpdateError`: No new update was found.
- `SUInstallationCanceledError`: The user canceled installing the update when requested for authorization.
@param updater The updater instance.
@param updateCheck The type of update check was performed.
@param error The error that caused the update driver to abort. This is @c nil if the update driver finished normally and there is no error.
*/
- (void)updater:(SPUUpdater *)updater didFinishUpdateCycleForUpdateCheck:(SPUUpdateCheck)updateCheck error:(nullable NSError *)error;
/* Deprecated methods */
- (BOOL)updaterMayCheckForUpdates:(SPUUpdater *)updater __deprecated_msg("Please use -[SPUUpdaterDelegate updater:mayPerformUpdateCheck:error:] instead.");
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,61 @@
//
// SPUUpdaterSettings.h
// Sparkle
//
// Created by Mayur Pawashe on 3/27/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
@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

View File

@ -0,0 +1,287 @@
//
// SPUUserDriver.h
// Sparkle
//
// Created by Mayur Pawashe on 2/14/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import <Sparkle/SPUUserUpdateState.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 can be assumed to be called from the main thread.
*/
SU_EXPORT @protocol SPUUserDriver <NSObject>
/**
* 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.
*/
- (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 cancellation Invoke this cancellation block to cancel the update check before the update check is completed.
*/
- (void)showUserInitiatedUpdateCheckWithCancellation:(void (^)(void))cancellation;
/**
* Show the user a new update is found.
*
* Let the user know a new update is found and ask them what they want to do.
* Before this point, `-showUserInitiatedUpdateCheckWithCancellation:` may be called.
*
* The potential `stage`s on the updater @c state are:
*
* `SPUUpdateStateNotDownloaded` - Update has not been downloaded yet.
*
* `SPUUpdateStateDownloaded` - Update has already been downloaded but not started installing yet.
*
* `SPUUpdateStateInstalling` - Update has been downloaded and already started installing.
*
* The `userIntiated` property on the @c state indicates if the update was initiated by the user or if it was automatically scheduled in the background.
*
* Additionally, these properties on the @c appcastItem are of importance:
*
* @c appcastItem.informationOnlyUpdate indicates if the update is only informational and should not be downloaded. You can direct the user to the infoURL property of the appcastItem in their web browser. Sometimes information only updates are used as a fallback in case a bad update is shipped, so you'll want to support this case.
*
* @c appcastItem.majorUpgrade indicates if the update is a major or paid upgrade.
*
* @c appcastItem.criticalUpdate indicates if the update is a critical update.
*
* A reply of `SPUUserUpdateChoiceInstall` begins or resumes downloading or installing the update.
* If the state.stage is `SPUUserUpdateStateInstalling`, this may send a quit event to the application and relaunch it immediately (in this state, this behaves as a fast "install and Relaunch").
* Do not use this reply if @c appcastItem.informationOnlyUpdate is YES.
*
* A reply of `SPUUserUpdateChoiceDismiss` dismisses the update for the time being. The user may be reminded of the update at a later point.
* If the state.stage is `SPUUserUpdateStateDownloaded`, the downloaded update is kept after dismissing until the next time an update is shown to the user.
* If the state.stage is `SPUUserUpdateStateInstalling`, the installing update is also preserved after dismissing. In this state however, the update will also still be installed after the application is terminated.
*
* A reply of `SPUUserUpdateChoiceSkip` skips this particular version and won't notify the user again, unless they initiate an update check themselves.
* If @c appcastItem.majorUpgrade is YES, the major update and any future minor updates to that major release are skipped, unless a future minor update specifies a `<sparkle:ignoreSkippedUpgradesBelowVersion>` requirement.
* If the state.stage is `SPUUpdateStateInstalling`, the installation is also canceled when the update is skipped.
*
* @param appcastItem The Appcast Item containing information that reflects the new update.
* @param state The current state of the user update. See above discussion for notable properties.
* @param reply The reply which indicates if the update should be installed, dismissed, or skipped. See above discussion for more details.
*/
- (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem state:(SPUUserUpdateState *)state reply:(void (^)(SPUUserUpdateChoice))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.
*/
- (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.
*/
- (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.
* Before this point, `-showUserInitiatedUpdateCheckWithCancellation:` may be called.
*
* There are various reasons a new update is unavailable and can't be installed.
* The @c error object is populated with recovery and suggestion strings suitable to be shown in an alert.
*
* The @c userInfo dictionary on the @c error is also populated with two keys:
*
* `SPULatestAppcastItemFoundKey`: if available, this may provide the latest SUAppcastItem that was found.
*
* `SPUNoUpdateFoundReasonKey`: if available, this will provide the `SUNoUpdateFoundReason`. For example the reason could be because
* the latest version in the feed requires a newer OS version or could be because the user is already on the latest version.
*
* @param error The error associated with why a new update was not found. See above discussion for more details.
* @param acknowledgement Acknowledge to the updater that no update found error was shown.
*/
- (void)showUpdateNotFoundWithError:(NSError *)error acknowledgement:(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.
*
* Before this point, any of the non-error user driver methods may have been invoked.
*
* @param error The error associated with what update error occurred.
* @param acknowledgement Acknowledge to the updater that the error was shown.
*/
- (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 cancellation Invoke this cancellation block to cancel the download at any point before `-showDownloadDidStartExtractingUpdate` is invoked.
*/
- (void)showDownloadInitiatedWithCancellation:(void (^)(void))cancellation;
/**
* 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.
*/
- (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
*/
- (void)showDownloadDidReceiveDataOfLength:(uint64_t)length;
/**
* Show the user that the update finished downloading and started extracting
*
* 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.
*/
- (void)showDownloadDidStartExtractingUpdate;
/**
* Show the user that the update is extracting with progress
*
* Let the user know how far along the update extraction is.
*
* Before this point, `-showDownloadDidStartExtractingUpdate` is called.
*
* @param progress The progress of the extraction from a 0.0 to 1.0 scale
*/
- (void)showExtractionReceivedProgress:(double)progress;
/**
* Show the user that the update is ready to install & relaunch
*
* Let the user know that the update is ready to install and relaunch, and ask them whether they want to proceed.
* Note if the target application has already terminated, this method may not be invoked.
*
* A reply of `SPUUserUpdateChoiceInstall` installs the update the new update immediately. The application is relaunched only if it is still running by the time this reply is invoked. If the application terminates on its own, Sparkle will attempt to automatically install the update.
*
* A reply of `SPUUserUpdateChoiceDismiss` dismisses the update installation for the time being. Note the update may still be installed automatically after the application terminates.
*
* A reply of `SPUUserUpdateChoiceSkip` cancels the current update that has begun installing and dismisses the update. In this circumstance, the update is canceled but this update version is not skipped in the future.
*
* Before this point, `-showExtractionReceivedProgress:` or `-showUpdateFoundWithAppcastItem:state:reply:` may be called.
*
* @param reply The reply which indicates if the update should be installed, dismissed, or skipped. See above discussion for more details.
*/
- (void)showReadyToInstallAndRelaunch:(void (^)(SPUUserUpdateChoice))reply;
/**
* Show the user that the update is installing
*
* Let the user know that the update is currently installing.
*
* Before this point, `-showReadyToInstallAndRelaunch:` or `-showUpdateFoundWithAppcastItem:state:reply:` will be called.
*
* @param applicationTerminated Indicates if the application has been terminated already.
* If the application hasn't been terminated, a quit event is sent to the running application before installing the update.
* If the application or user delays or cancels termination, there may be an indefinite period of time before the application fully quits.
* It is up to the implementor whether or not to decide to continue showing installation progress in this case.
*/
- (void)showInstallingUpdateWithApplicationTerminated:(BOOL)applicationTerminated;
/**
* 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. This implementation must not try to reference
* the old bundle prior to the installation, which will no longer be around.
*
* Before this point, `-showInstallingUpdateWithApplicationTerminated:` will be called.
*
* @param relaunched Indicates if the update was relaunched.
* @param acknowledgement Acknowledge to the updater that the finished installation was shown.
*/
- (void)showUpdateInstalledAndRelaunched:(BOOL)relaunched acknowledgement:(void (^)(void))acknowledgement;
/**
* Show the user the current presented update or its progress in utmost focus
*
* The user wishes to check for updates while the user is being shown update progress.
* Bring whatever is on screen to frontmost focus (permission request, update information, downloading or extraction status, choice to install update, etc).
*/
- (void)showUpdateInFocus;
/**
* Dismiss the current update installation
*
* Stop and tear down everything.
* 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.
*/
- (void)dismissUpdateInstallation;
/*
* Below are deprecated methods that have been replaced by better alternatives.
* The deprecated methods will be used if the alternatives have not been implemented yet.
* In the future support for using these deprecated methods may be removed however.
*/
@optional
// Clients should move to non-deprecated methods
// Deprecated methods are only (temporarily) kept around for compatibility reasons
- (void)showUpdateNotFoundWithAcknowledgement:(void (^)(void))acknowledgement __deprecated_msg("Implement -showUpdateNotFoundWithError:acknowledgement: instead");
- (void)showUpdateInstallationDidFinishWithAcknowledgement:(void (^)(void))acknowledgement __deprecated_msg("Implement -showUpdateInstalledAndRelaunched:acknowledgement: instead");
- (void)dismissUserInitiatedUpdateCheck __deprecated_msg("Transition to new UI appropriately when a new update is shown, when no update is found, or when an update error occurs.");
- (void)showInstallingUpdate __deprecated_msg("Implement -showInstallingUpdateWithApplicationTerminated: instead.");
- (void)showSendingTerminationSignal __deprecated_msg("Implement -showInstallingUpdateWithApplicationTerminated: instead.");
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,84 @@
//
// SPUUserUpdateState.h
// Sparkle
//
// Created by Mayur Pawashe on 2/29/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#ifndef SPUUserUpdateState_h
#define SPUUserUpdateState_h
#if __has_feature(modules)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import <Sparkle/SUExport.h>
NS_ASSUME_NONNULL_BEGIN
/**
A choice made by the user when prompted with a new update.
*/
typedef NS_ENUM(NSInteger, SPUUserUpdateChoice) {
/**
Dismisses the update and skips being notified of it in the future.
*/
SPUUserUpdateChoiceSkip,
/**
Downloads (if needed) and installs the update.
*/
SPUUserUpdateChoiceInstall,
/**
Dismisses the update until Sparkle reminds the user of it at a later time.
*/
SPUUserUpdateChoiceDismiss,
};
/**
Describes the current stage an update is undergoing.
*/
typedef NS_ENUM(NSInteger, SPUUserUpdateStage) {
/**
The update has not been downloaded.
*/
SPUUserUpdateStageNotDownloaded,
/**
The update has already been downloaded but not begun installing.
*/
SPUUserUpdateStageDownloaded,
/**
The update has already been downloaded and began installing in the background.
*/
SPUUserUpdateStageInstalling
};
/**
This represents the user's current update state.
*/
SU_EXPORT @interface SPUUserUpdateState : NSObject
- (instancetype)init NS_UNAVAILABLE;
/**
The current update stage.
This stage indicates if data has been already downloaded or not, or if an update is currently being installed.
*/
@property (nonatomic, readonly) SPUUserUpdateStage stage;
/**
Indicates whether or not the update check was initiated by the user.
*/
@property (nonatomic, readonly) BOOL userInitiated;
@end
NS_ASSUME_NONNULL_END
#endif /* SPUUserUpdateState_h */

View File

@ -0,0 +1,44 @@
//
// 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)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import <Sparkle/SUExport.h>
NS_ASSUME_NONNULL_BEGIN
@class SUAppcastItem;
/**
The appcast representing a collection of `SUAppcastItem` items in the feed.
*/
SU_EXPORT @interface SUAppcast : NSObject
- (instancetype)init NS_UNAVAILABLE;
/**
The collection of update items.
These `SUAppcastItem` items are in the same order as specified in the appcast XML feed and are thus not sorted by version.
*/
@property (readonly, copy) NSArray<SUAppcastItem *> *items;
@end
NS_ASSUME_NONNULL_END
#endif

View File

@ -0,0 +1,376 @@
//
// 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)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#ifdef BUILDING_SPARKLE_TESTS
// Ignore incorrect warning
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wquoted-include-in-framework-header"
#import "SUExport.h"
#pragma clang diagnostic pop
#else
#import <Sparkle/SUExport.h>
#endif
@class SUSignatures;
@class SPUAppcastItemState;
NS_ASSUME_NONNULL_BEGIN
/**
The appcast item describing an update in the application's appcast feed.
An appcast item represents a single update item in the `SUAppcast` contained within the @c <item> element.
Every appcast item must have a `versionString`, and either a `fileURL` or an `infoURL`.
All the remaining properties describing an update to the application are optional.
Extended documentation and examples on using appcast item features are available at:
https://sparkle-project.org/documentation/publishing/
*/
SU_EXPORT @interface SUAppcastItem : NSObject<NSSecureCoding>
/**
The version of the update item.
Sparkle uses this property to compare update items and determine the best available update item in the `SUAppcast`.
This corresponds to the application update's @c CFBundleVersion
This is extracted from the @c <sparkle:version> element, or the @c sparkle:version attribute from the @c <enclosure> element.
*/
@property (copy, readonly) NSString *versionString;
/**
The human-readable display version of the update item if provided.
This is the version string shown to the user when they are notified of a new update.
This corresponds to the application update's @c CFBundleShortVersionString
This is extracted from the @c <sparkle:shortVersionString> element, or the @c sparkle:shortVersionString attribute from the @c <enclosure> element.
*/
@property (copy, readonly, nullable) NSString *displayVersionString;
/**
The file URL to the update item if provided.
This download contains the actual update Sparkle will attempt to install.
In cases where a download cannot be provided, an `infoURL` must be provided instead.
A file URL should have an accompanying `contentLength` provided.
This is extracted from the @c url attribute in the @c <enclosure> element.
*/
@property (readonly, nullable) NSURL *fileURL;
/**
The content length of the download in bytes.
This property is used as a fallback when the server doesn't report the content length of the download.
In that case, it is used to report progress of the downloading update to the user.
A warning is outputted if this property is not equal the server's expected content length (if provided).
This is extracted from the @c length attribute in the @c <enclosure> element.
It should be specified if a `fileURL` is provided.
*/
@property (nonatomic, readonly) uint64_t contentLength;
/**
The info URL to the update item if provided.
This informational link is used to direct the user to learn more about an update they cannot download/install directly from within the application.
The link should point to the product's web page.
The informational link will be used if `informationOnlyUpdate` is @c YES
This is extracted from the @c <link> element.
*/
@property (readonly, nullable) NSURL *infoURL;
/**
Indicates whether or not the update item is only informational and has no download.
If `infoURL` is not present, this is @c NO
If `fileURL` is not present, this is @c YES
Otherwise this is determined based on the contents extracted from the @c <sparkle:informationalUpdate> element.
*/
@property (getter=isInformationOnlyUpdate, readonly) BOOL informationOnlyUpdate;
/**
The title of the appcast item if provided.
This is extracted from the @c <title> element.
*/
@property (copy, readonly, nullable) NSString *title;
/**
The date string of the appcast item if provided.
The `date` property is constructed from this property and expects this string to comply with the following date format:
`E, dd MMM yyyy HH:mm:ss Z`
This is extracted from the @c <pubDate> element.
*/
@property (copy, readonly, nullable) NSString *dateString;
/**
The date constructed from the `dateString` property if provided.
Sparkle by itself only uses this property for phased group rollouts specified via `phasedRolloutInterval`, but clients may query this property too.
This date is constructed using the @c en_US locale.
*/
@property (copy, readonly, nullable) NSDate *date;
/**
The release notes URL of the appcast item if provided.
This external link points to an HTML file that Sparkle downloads and renders to show the user a new or old update item's changelog.
An alternative to using an external release notes link is providing an embedded `itemDescription`.
This is extracted from the @c <sparkle:releaseNotesLink> element.
*/
@property (readonly, nullable) NSURL *releaseNotesURL;
/**
The description of the appcast item if provided.
A description may be provided for inline/embedded release notes for new updates using @c <![CDATA[...]]>
This is an alternative to providing a `releaseNotesURL`.
This is extracted from the @c <description> element.
*/
@property (copy, readonly, nullable) NSString *itemDescription;
/**
The full release notes URL of the appcast item if provided.
The link should point to the product's full changelog.
Sparkle's standard user interface offers to show these full release notes when a user checks for a new update and no new update is available.
This is extracted from the @c <sparkle:fullReleaseNotesLink> element.
*/
@property (readonly, nullable) NSURL *fullReleaseNotesURL;
/**
The required minimum system operating version string for this update if provided.
This version string should contain three period-separated components.
Example: @c 10.12.0
Use `minimumOperatingSystemVersionIsOK` property to test if the current running system passes this requirement.
This is extracted from the @c <sparkle:minimumSystemVersion> element.
*/
@property (copy, readonly, nullable) NSString *minimumSystemVersion;
/**
Indicates whether or not the current running system passes the `minimumSystemVersion` requirement.
*/
@property (nonatomic, readonly) BOOL minimumOperatingSystemVersionIsOK;
/**
The required maximum system operating version string for this update if provided.
A maximum system operating version requirement should only be made in unusual scenarios.
This version string should contain three period-separated components.
Example: @c 10.13.0
Use `maximumOperatingSystemVersionIsOK` property to test if the current running system passes this requirement.
This is extracted from the @c <sparkle:maximumSystemVersion> element.
*/
@property (copy, readonly, nullable) NSString *maximumSystemVersion;
/**
Indicates whether or not the current running system passes the `maximumSystemVersion` requirement.
*/
@property (nonatomic, readonly) BOOL maximumOperatingSystemVersionIsOK;
/**
The channel the update item is on if provided.
An update item may specify a custom channel name (such as @c beta) that can only be found by updaters that filter for that channel.
If no channel is provided, the update item is assumed to be on the default channel.
This is extracted from the @c <sparkle:channel> element.
Old applications must be using Sparkle 2 or later to interpret the channel element and to ignore unmatched channels.
*/
@property (nonatomic, readonly, nullable) NSString *channel;
/**
The installation type of the update at `fileURL`
This may be:
- @c application - indicates this is a regular application update.
- @c package - indicates this is a guided package installer update.
- @c interactive-package - indicates this is an interactive package installer update (deprecated; use "package" instead)
This is extracted from the @c sparkle:installationType attribute in the @c <enclosure> element.
If no installation type is provided in the enclosure, the installation type is inferred from the `fileURL` file extension instead.
If the file extension is @c pkg or @c mpkg, the installation type is @c package otherwise it is @c application
Hence, the installation type in the enclosure element only needs to be specified for package based updates distributed inside of a @c zip or other archive format.
Old applications must be using Sparkle 1.26 or later to support downloading bare package updates (`pkg` or `mpkg`) that are not additionally archived inside of a @c zip or other archive format.
*/
@property (nonatomic, copy, readonly) NSString *installationType;
/**
The phased rollout interval of the update item in seconds if provided.
This is the interval between when different groups of users are notified of a new update.
For this property to be used by Sparkle, the published `date` on the update item must be present as well.
After each interval after the update item's `date`, a new group of users become eligible for being notified of the new update.
This is extracted from the @c <sparkle:phasedRolloutInterval> element.
Old applications must be using Sparkle 1.25 or later to support phased rollout intervals, otherwise they may assume updates are immediately available.
*/
@property (copy, readonly, nullable) NSNumber* phasedRolloutInterval;
/**
The minimum bundle version string this update requires for automatically downloading and installing updates if provided.
If an application's bundle version meets this version requirement, it can install the new update item in the background automatically.
Otherwise if the requirement is not met, the user is always prompted to install the update. In this case, the update is assumed to be a `majorUpgrade`.
If the update is a `majorUpgrade` and the update is skipped by the user, other future update alerts with the same `minimumAutoupdateVersion` will also be skipped automatically unless an update specifies `ignoreSkippedUpgradesBelowVersion`.
This version string corresponds to the application's @c CFBundleVersion
This is extracted from the @c <sparkle:minimumAutoupdateVersion> element.
*/
@property (copy, readonly, nullable) NSString *minimumAutoupdateVersion;
/**
Indicates whether or not the update item is a major upgrade.
An update is a major upgrade if the application's bundle version doesn't meet the `minimumAutoupdateVersion` requirement.
*/
@property (getter=isMajorUpgrade, readonly) BOOL majorUpgrade;
/**
Previously skipped upgrades by the user will be ignored if they skipped an update whose version precedes this version.
This can only be applied if the update is a `majorUpgrade`.
This version string corresponds to the application's @c CFBundleVersion
This is extracted from the @c <sparkle:ignoreSkippedUpgradesBelowVersion> element.
Old applications must be using Sparkle 2.1 or later, otherwise this property will be ignored.
*/
@property (nonatomic, readonly, nullable) NSString *ignoreSkippedUpgradesBelowVersion;
/**
Indicates whether or not the update item is critical.
Critical updates are shown to the user more promptly. Sparkle's standard user interface also does not allow them to be skipped.
This is determined and extracted from a top-level @c <sparkle:criticalUpdate> element or a @c sparkle:criticalUpdate element inside of a @c sparkle:tags element.
Old applications must be using Sparkle 2 or later to support the top-level @c <sparkle:criticalUpdate> element.
*/
@property (getter=isCriticalUpdate, readonly) BOOL criticalUpdate;
/**
Specifies the operating system the download update is available for if provided.
If this property is not provided, then the supported operating system is assumed to be macOS.
Known potential values for this string are @c macos and @c windows
Sparkle on Mac ignores update items that are for other operating systems.
This is only useful for sharing appcasts between Sparkle on Mac and Sparkle on other operating systems.
Use `macOsUpdate` property to test if this update item is for macOS.
This is extracted from the @c sparkle:os attribute in the @c <enclosure> element.
*/
@property (copy, readonly, nullable) NSString *osString;
/**
Indicates whether or not this update item is for macOS.
This is determined from the `osString` property.
*/
@property (getter=isMacOsUpdate, readonly) BOOL macOsUpdate;
/**
The delta updates for this update item.
Sparkle uses these to download and apply a smaller update based on the version the user is updating from.
The key is based on the @c sparkle:version of the update.
The value is an update item that will have `deltaUpdate` be @c YES
Clients typically should not need to examine the contents of the delta updates.
This is extracted from the @c <sparkle:deltas> element.
*/
@property (copy, readonly, nullable) NSDictionary<NSString *, SUAppcastItem *> *deltaUpdates;
/**
Indicates whether or not the update item is a delta update.
An update item is a delta update if it is in the `deltaUpdates` of another update item.
*/
@property (getter=isDeltaUpdate, readonly) BOOL deltaUpdate;
/**
The dictionary representing the entire appcast item.
This is useful for querying custom extensions or elements from the appcast item.
*/
@property (readonly, copy) NSDictionary *propertiesDictionary;
- (instancetype)init NS_UNAVAILABLE;
/**
An empty appcast item.
This may be used as a potential return value in `-[SPUUpdaterDelegate bestValidUpdateInAppcast:forUpdater:]`
*/
+ (instancetype)emptyAppcastItem;
// Deprecated initializers
- (nullable instancetype)initWithDictionary:(NSDictionary *)dict __deprecated_msg("Properties that depend on the system or application version are not supported when used with this initializer. The designated initializer is available in SUAppcastItem+Private.h. Please first explore other APIs or contact us to describe your use case.");
- (nullable instancetype)initWithDictionary:(NSDictionary *)dict failureReason:(NSString * _Nullable __autoreleasing *_Nullable)error __deprecated_msg("Properties that depend on the system or application version are not supported when used with this initializer. The designated initializer is available in SUAppcastItem+Private.h. Please first explore other APIs or contact us to describe your use case.");
- (nullable instancetype)initWithDictionary:(NSDictionary *)dict relativeToURL:(NSURL * _Nullable)appcastURL failureReason:(NSString * _Nullable __autoreleasing *_Nullable)error __deprecated_msg("Properties that depend on the system or application version are not supported when used with this initializer. The designated initializer is available in SUAppcastItem+Private.h. Please first explore other APIs or contact us to describe your use case.");
@end
NS_ASSUME_NONNULL_END
#endif

View File

@ -0,0 +1,111 @@
//
// 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)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#if defined(BUILDING_SPARKLE_TOOL) || defined(BUILDING_SPARKLE_TESTS)
// Ignore incorrect warning
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wquoted-include-in-framework-header"
#import "SUExport.h"
#pragma clang diagnostic pop
#else
#import <Sparkle/SUExport.h>
#endif
/**
* 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,
SURunningTranslocated = 1005,
SUWebKitTerminationError = 1006,
// Download phase errors.
SUTemporaryDirectoryError = 2000,
SUDownloadError = 2001,
// Extraction phase errors.
SUUnarchivingError = 3000,
SUSignatureError = 3001,
SUValidationError = 3002,
// Installation phase errors.
SUFileCopyFailure = 4000,
SUAuthenticationFailure = 4001,
SUMissingUpdateError = 4002,
SUMissingInstallerToolError = 4003,
SURelaunchError = 4004,
SUInstallationError = 4005,
SUDowngradeError = 4006,
SUInstallationCanceledError = 4007,
SUInstallationAuthorizeLaterError = 4008,
SUNotValidUpdateError = 4009,
SUAgentInvalidationError = 4010,
// API misuse errors.
SUIncorrectAPIUsageError = 5000
};
/**
The reason why a new update is not available.
*/
typedef NS_ENUM(OSStatus, SPUNoUpdateFoundReason) {
/**
A new update is unavailable for an unknown reason.
*/
SPUNoUpdateFoundReasonUnknown,
/**
A new update is unavailable because the user is on the latest known version in the appcast feed.
*/
SPUNoUpdateFoundReasonOnLatestVersion,
/**
A new update is unavailable because the user is on a version newer than the latest known version in the appcast feed.
*/
SPUNoUpdateFoundReasonOnNewerThanLatestVersion,
/**
A new update is unavailable because the user's operating system version is too old for the update.
*/
SPUNoUpdateFoundReasonSystemIsTooOld,
/**
A new update is unavailable because the user's operating system version is too new for the update.
*/
SPUNoUpdateFoundReasonSystemIsTooNew
};
SU_EXPORT extern NSString *const SPUNoUpdateFoundReasonKey;
SU_EXPORT extern NSString *const SPULatestAppcastItemFoundKey;
SU_EXPORT extern NSString *const SPUNoUpdateFoundUserInitiatedKey;
#endif

View File

@ -0,0 +1,70 @@
//
// 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)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#ifdef BUILDING_SPARKLE_TOOL
// Ignore incorrect warning
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wquoted-include-in-framework-header"
#import "SUExport.h"
#import "SUVersionComparisonProtocol.h"
#pragma clang diagnostic pop
#else
#import <Sparkle/SUExport.h>
#import <Sparkle/SUVersionComparisonProtocol.h>
#endif
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;
/**
A singleton instance of the comparator.
*/
@property (nonatomic, class, readonly) SUStandardVersionComparator *defaultComparator;
/**
Compares two version strings through textual analysis.
These version strings should be in the format of x, x.y, or x.y.z where each component is a number.
For example, valid version strings include "1.5.3", "500", or "4000.1"
These versions that are compared correspond to the @c CFBundleVersion values of the updates.
@param versionA The first version string to compare.
@param versionB The second version string to compare.
@return A comparison result between @c versionA and @c versionB
*/
- (NSComparisonResult)compareVersion:(NSString *)versionA toVersion:(NSString *)versionB;
@end
NS_ASSUME_NONNULL_END
#endif

View File

@ -0,0 +1,47 @@
//
// SUUpdatePermissionResponse.h
// Sparkle
//
// Created by Mayur Pawashe on 2/8/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
@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;
/*
Use -initWithAutomaticUpdateChecks:sendSystemProfile: instead.
*/
- (instancetype)init NS_UNAVAILABLE;
/**
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

View File

@ -10,27 +10,33 @@
#define SUUPDATER_H
#if __has_feature(modules)
@import Cocoa;
#else
#import <Cocoa/Cocoa.h>
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
#import "SUExport.h"
#import "SUVersionComparisonProtocol.h"
#import "SUVersionDisplayProtocol.h"
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import <Sparkle/SUExport.h>
#import <Sparkle/SUVersionComparisonProtocol.h>
#import <Sparkle/SUVersionDisplayProtocol.h>
#import <Sparkle/SUUpdaterDelegate.h>
@class SUAppcastItem, SUAppcast;
@class SUAppcastItem, SUAppcast, NSMenuItem;
@protocol SUUpdaterDelegate;
/*!
The main API in Sparkle for controlling the update mechanism.
/**
The legacy 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.
This class is now deprecated and acts as a thin wrapper around `SPUUpdater` and `SPUStandardUserDriver`.
If you are migrating to Sparkle 2, use `SPUStandardUpdaterController` instead, or `SPUUpdater` if you need more control.
*/
__deprecated_msg("Deprecated in Sparkle 2. Use SPUStandardUpdaterController instead, or SPUUpdater if you need more control.")
SU_EXPORT @interface SUUpdater : NSObject
@property (unsafe_unretained) IBOutlet id<SUUpdaterDelegate> delegate;
@property (unsafe_unretained, nonatomic) IBOutlet id<SUUpdaterDelegate> delegate;
/*!
The shared updater for the main bundle.
@ -41,7 +47,6 @@ SU_EXPORT @interface SUUpdater : NSObject
/*!
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;
@ -92,18 +97,17 @@ SU_EXPORT @interface SUUpdater : NSObject
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 BOOL automaticallyChecksForUpdates;
@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
or by the user's system if silent updates cannot be done (eg: if they require authentication).
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 BOOL automaticallyDownloadsUpdates;
@property (nonatomic) BOOL automaticallyDownloadsUpdates;
/*!
A property indicating the current automatic update check interval.
@ -112,7 +116,7 @@ SU_EXPORT @interface SUUpdater : NSObject
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 NSTimeInterval updateCheckInterval;
@property (nonatomic) NSTimeInterval updateCheckInterval;
/*!
Begins a "probing" check for updates which will not actually offer to
@ -136,17 +140,17 @@ SU_EXPORT @interface SUUpdater : NSObject
This property must be called on the main thread.
*/
@property (copy) NSURL *feedURL;
@property (nonatomic, copy) NSURL *feedURL;
/*!
The host bundle that is being updated.
*/
@property (readonly, strong) NSBundle *hostBundle;
@property (readonly, nonatomic) NSBundle *hostBundle;
/*!
The bundle this class (SUUpdater) is loaded into.
*/
@property (strong, readonly) NSBundle *sparkleBundle;
@property (nonatomic, readonly) NSBundle *sparkleBundle;
/*!
The user agent used when checking for and downloading updates.
@ -167,7 +171,7 @@ SU_EXPORT @interface SUUpdater : NSObject
Setting this property will persist in the host bundle's user defaults.
*/
@property BOOL sendsSystemProfile;
@property (nonatomic) BOOL sendsSystemProfile;
/*!
A property indicating the decryption password used for extracting updates shipped as Apple Disk Images (dmg)
@ -175,58 +179,28 @@ SU_EXPORT @interface SUUpdater : NSObject
@property (nonatomic, copy) NSString *decryptionPassword;
/*!
This function ignores normal update schedule, ignores user preferences,
and interrupts users with an unwanted immediate app update.
Returns the date of last update check.
WARNING: this function should not be used in regular apps. This function
is a user-unfriendly hack only for very special cases, like unstable
rapidly-changing beta builds that would not run correctly if they were
even one day out of date.
Instead of this function you should set `SUAutomaticallyUpdate` to `YES`,
which will gracefully install updates when the app quits.
For UI-less/daemon apps that aren't usually quit, instead of this function,
you can use the delegate method
SUUpdaterDelegate::updater:willInstallUpdateOnQuit:immediateInstallationInvocation:
or
SUUpdaterDelegate::updater:willInstallUpdateOnQuit:immediateInstallationBlock:
to immediately start installation when an update was found.
A progress dialog is shown but the user will never be prompted to read the
release notes.
This function will cause update to be downloaded twice if automatic updates are
enabled.
You may want to respond to the userDidCancelDownload delegate method in case
the user clicks the "Cancel" button while the update is downloading.
\returns \c nil if no check has been performed.
*/
- (void)installUpdatesIfAvailable __attribute__((deprecated("This method is deprecated. Please set SUAutomaticallyUpdate in your Info.plist or use automaticallyDownloadsUpdates property instead.")));
@property (nonatomic, readonly, copy) NSDate *lastUpdateCheckDate;
/*!
Returns the date of last update check.
Appropriately schedules or cancels the update checking timer according to
the preferences for time interval and automatic checks.
\returns \c nil if no check has been performed.
*/
@property (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.
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.
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.
Note this property is not indicative of whether or not user initiated updates can be performed.
Use SUUpdater::validateMenuItem: for that instead.
*/
@property (readonly) BOOL updateInProgress;
@property (nonatomic, readonly) BOOL updateInProgress;
@end

View File

@ -2,17 +2,19 @@
// SUUpdaterDelegate.h
// Sparkle
//
// Created by Mayur Pawashe on 12/25/16.
// Created by Mayur Pawashe on 3/12/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import "SUExport.h"
#import <Sparkle/SUExport.h>
@protocol SUVersionComparison, SUVersionDisplay;
@class SUUpdater, SUAppcast, SUAppcastItem;
@ -36,12 +38,13 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastItemNotificationKey;
SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
// -----------------------------------------------------------------------------
// SUUpdater Delegate:
// SUUpdater Delegate:
// -----------------------------------------------------------------------------
/*!
Provides methods to control the behavior of an SUUpdater object.
*/
__deprecated_msg("Deprecated in Sparkle 2. See SPUUpdaterDelegate instead")
@protocol SUUpdaterDelegate <NSObject>
@optional
@ -117,23 +120,6 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
*/
- (void)updater:(SUUpdater *)updater didFindValidUpdate:(SUAppcastItem *)item;
/*!
Called just before the scheduled update driver prompts the user to install an update.
\param updater The SUUpdater instance.
\return YES to allow the update prompt to be shown (the default behavior), or NO to suppress it.
*/
- (BOOL)updaterShouldShowUpdateAlertForScheduledUpdate:(SUUpdater *)updater forItem:(SUAppcastItem *)item;
/*!
Called after the user dismisses the update alert.
\param updater The SUUpdater instance.
\param permanently YES if the alert will not appear again for this update; NO if it may reappear.
*/
- (void)updater:(SUUpdater *)updater didDismissUpdateAlertPermanently:(BOOL)permanently forItem:(SUAppcastItem *)item;
/*!
Called when a valid update is not found.
@ -141,13 +127,6 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
*/
- (void)updaterDidNotFindUpdate:(SUUpdater *)updater;
/*!
Called when the user clicks the Skip This Version button.
\param updater The SUUpdater instance.
*/
- (void)updater:(SUUpdater *)updater userDidSkipThisVersion:(SUAppcastItem *)item;
/*!
Called immediately before downloading the specified update.
@ -205,12 +184,22 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
*/
- (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)item;
/*!
Called when an update is skipped by the user.
\param updater The updater instance.
\param item The appcast item corresponding to the update that the user skipped.
*/
- (void)updater:(SUUpdater *)updater userDidSkipThisVersion:(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.
@ -221,15 +210,15 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
/*!
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 method acts as a simpler alternative to SUUpdaterDelegate::updater:shouldPostponeRelaunchForUpdate:untilInvoking: avoiding usage of NSInvocation, which is not available in Swift environments.
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that is proposed to be installed.
\return \c YES to delay the relaunch.
*/
- (BOOL)updater:(SUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)item;
@ -263,7 +252,9 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
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.
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
@ -273,18 +264,17 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
/*!
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.
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;
- (nullable id <SUVersionDisplay>)versionDisplayerForUpdater:(SUUpdater *)updater;
/*!
Returns the path which is used to relaunch the client after the update is installed.
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.
@ -310,6 +300,7 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
/*!
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)
@ -324,7 +315,6 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
This is after an update has been automatically downloaded in the background.
(i.e. SUUpdater::automaticallyDownloadsUpdates is YES)
This method acts as a more modern alternative to SUUpdaterDelegate::updater:willInstallUpdateOnQuit:immediateInstallationInvocation: using a block instead of NSInvocation, which is not available in Swift environments.
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that is proposed to be installed.
\param installationBlock Can be used to trigger an immediate silent install and relaunch.
@ -336,8 +326,10 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
\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;
- (void)updater:(SUUpdater *)updater didCancelInstallUpdateOnQuit:(SUAppcastItem *)item __deprecated;
/*!
Called after an update is aborted due to an error.

View File

@ -10,20 +10,32 @@
#define SUVERSIONCOMPARISONPROTOCOL_H
#if __has_feature(modules)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#ifdef BUILDING_SPARKLE_TOOL
// Ignore incorrect warning
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wquoted-include-in-framework-header"
#import "SUExport.h"
#pragma clang diagnostic pop
#else
#import <Sparkle/SUExport.h>
#endif
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,

View File

@ -7,18 +7,21 @@
//
#if __has_feature(modules)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import "SUExport.h"
#import <Sparkle/SUExport.h>
/*!
/**
Applies special display formatting to version numbers.
*/
@protocol SUVersionDisplay
SU_EXPORT @protocol SUVersionDisplay
/*!
/**
Formats two version strings.
Both versions are provided so that important distinguishing information

View File

@ -0,0 +1,39 @@
//
// 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/SUVersionComparisonProtocol.h>
#import <Sparkle/SUVersionDisplayProtocol.h>
#import <Sparkle/SUErrors.h>
#import <Sparkle/SPUUpdatePermissionRequest.h>
#import <Sparkle/SUUpdatePermissionResponse.h>
#import <Sparkle/SPUUserDriver.h>
#import <Sparkle/SPUDownloadData.h>
// UI bits
#import <Sparkle/SPUStandardUpdaterController.h>
#import <Sparkle/SPUStandardUserDriver.h>
#import <Sparkle/SPUStandardUserDriverDelegate.h>
// Deprecated bits
#import <Sparkle/SUUpdater.h>
#import <Sparkle/SUUpdaterDelegate.h>
#endif

View File

@ -0,0 +1,37 @@
//
// SPUAppcastItemStateResolver.h
// Sparkle
//
// Created by Mayur Pawashe on 5/31/21.
// Copyright © 2021 Sparkle Project. All rights reserved.
//
#if __has_feature(modules)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import <Sparkle/SUExport.h>
NS_ASSUME_NONNULL_BEGIN
@class SUStandardVersionComparator, SPUAppcastItemState;
@protocol SUVersionComparison;
/**
Private exposed class used to resolve Appcast Item properties that rely on external factors such as a host.
This resolver is used for constructing appcast items.
*/
SU_EXPORT @interface SPUAppcastItemStateResolver : NSObject
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithHostVersion:(NSString *)hostVersion applicationVersionComparator:(id<SUVersionComparison>)applicationVersionComparator standardVersionComparator:(SUStandardVersionComparator *)standardVersionComparator;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,19 @@
//
// SPUInstallationType.h
// Sparkle
//
// Created by Mayur Pawashe on 7/24/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#ifndef SPUInstallationType_h
#define SPUInstallationType_h
#define SPUInstallationTypeApplication @"application" // the default installation type for ordinary application updates
#define SPUInstallationTypeGuidedPackage @"package" // the preferred installation type for package installations
#define SPUInstallationTypeInteractivePackage @"interactive-package" // the deprecated installation type; use guided package instead
#define SPUInstallationTypesArray (@[SPUInstallationTypeApplication, SPUInstallationTypeGuidedPackage, SPUInstallationTypeInteractivePackage])
#define SPUValidInstallationType(x) ((x != nil) && [SPUInstallationTypesArray containsObject:(NSString * _Nonnull)x])
#endif /* SPUInstallationType_h */

View File

@ -0,0 +1,20 @@
//
// SPUUserAgent+Private.h
// Sparkle
//
// Created by Mayur Pawashe on 11/12/21.
// Copyright © 2021 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <Sparkle/SUExport.h>
NS_ASSUME_NONNULL_BEGIN
@class SUHost;
SU_EXPORT NSString *SPUMakeUserAgentWithHost(SUHost *responsibleHost, NSString * _Nullable displayNameSuffix);
SU_EXPORT NSString *SPUMakeUserAgentWithBundle(NSBundle *responsibleBundle, NSString * _Nullable displayNameSuffix);
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,45 @@
//
// SUAppcastItem+Private.h
// Sparkle
//
// Created by Mayur Pawashe on 4/30/21.
// Copyright © 2021 Sparkle Project. All rights reserved.
//
#ifndef SUAppcastItem_Private_h
#define SUAppcastItem_Private_h
#if __has_feature(modules)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
NS_ASSUME_NONNULL_BEGIN
// Available in SPUAppcastItemStateResolver.h (a private exposed header)
@class SPUAppcastItemStateResolver;
@interface SUAppcastItem (Private) <NSSecureCoding>
/**
Initializes with data from a dictionary provided by the RSS class and state resolver
This initializer method is intended to be marked "private" and discouraged from public usage.
This method is available however. Talk to us to describe your use case and if you need to construct appcast items yourself.
*/
- (nullable instancetype)initWithDictionary:(NSDictionary *)dict relativeToURL:(NSURL * _Nullable)appcastURL stateResolver:(SPUAppcastItemStateResolver *)stateResolver failureReason:(NSString * _Nullable __autoreleasing *_Nullable)error;
/**
The DSA and EdDSA signatures along with their statuses.
*/
@property (readonly, nullable) SUSignatures *signatures;
@end
NS_ASSUME_NONNULL_END
#endif /* SUAppcastItem_Private_h */

View File

@ -0,0 +1,29 @@
//
// SUInstallerLauncher+Private.h
// SUInstallerLauncher+Private
//
// Created by Mayur Pawashe on 8/21/21.
// Copyright © 2021 Sparkle Project. All rights reserved.
//
#ifndef SUInstallerLauncher_Private_h
#define SUInstallerLauncher_Private_h
#import <Sparkle/SUExport.h>
// Chances are clients will need this too
#import <Sparkle/SPUInstallationType.h>
@class NSString;
/**
Private API for determining if the system needs authorization access to update a bundle path
This API is not supported when used directly from a Sandboxed applications and will always return @c YES in that case.
@param bundlePath The bundle path to test if authorization is needed when performing an update that replaces this bundle.
@return @c YES if Sparkle thinks authorization is needed to update the @c bundlePath, otherwise @c NO.
*/
SU_EXPORT BOOL SPUSystemNeedsAuthorizationAccessForBundlePath(NSString *bundlePath);
#endif /* SUInstallerLauncher_Private_h */

Some files were not shown because too many files have changed in this diff Show More